Skip to content

Commit d3afb99

Browse files
authored
fix my sloppy oversight of asUint8 missing unchecked suffix in asBool… (#25)
* fix my sloppy oversight of asUint8 missing unchecked suffix in asBoolUnchecked * fix remove assembly which fails to account for dirty upper 31 bytes * hopefully more efficient impl
1 parent 374a016 commit d3afb99

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libraries/BytesParsing.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ library BytesParsing {
9696
bytes memory encoded,
9797
uint offset
9898
) internal pure returns (bool, uint) {
99-
(uint8 val, uint nextOffset) = asUint8(encoded, offset);
99+
(uint8 val, uint nextOffset) = asUint8Unchecked(encoded, offset);
100100
if (val & 0xfe != 0)
101101
revert InvalidBoolVal(val);
102102

103+
uint cleanedVal = uint(val);
103104
bool ret;
105+
//skip 2x iszero opcode
104106
assembly ("memory-safe") {
105-
ret := val
107+
ret := cleanedVal
106108
}
107109
return (ret, nextOffset);
108110
}

0 commit comments

Comments
 (0)