Skip to content

Commit f304468

Browse files
feat: minor gas optimization (#183)
slightly less memory ops in `orderedBytesArrayToBitmap` fnc
1 parent 2262079 commit f304468

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/libraries/BitmapUtils.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,9 @@ library BitmapUtils {
6262
function orderedBytesArrayToBitmap(bytes memory orderedBytesArray, uint8 bitUpperBound) internal pure returns (uint256) {
6363
uint256 bitmap = orderedBytesArrayToBitmap(orderedBytesArray);
6464

65-
if (bitmap != 0) {
66-
require(
67-
uint8(orderedBytesArray[orderedBytesArray.length - 1]) < bitUpperBound,
68-
"BitmapUtils.orderedBytesArrayToBitmap: bitmap exceeds max value"
69-
);
70-
}
65+
require((1 << bitUpperBound) > bitmap,
66+
"BitmapUtils.orderedBytesArrayToBitmap: bitmap exceeds max value"
67+
);
7168

7269
return bitmap;
7370
}

0 commit comments

Comments
 (0)