OpenSea Rinkeby is able to detect the events as per normal.
Saves 36 gas for the first mint and 28 gas per additional iteration
(28 / 1958 ≈ 1.4% savings per additional iteration).
The variables and statements have been carefully arranged to ensure that the compiler is as well behaved as possible. (actually, it can perform better than 100% handwritten Yul cuz Solidity provides high level semantics that can aid optimizations).
iszero(eq(tokenId, end)) is more efficient than lt(tokenId, end)
because of how the compiler implicitly adds a iszero for the lt, and removes the iszero for the eq.
Moving the zero address check after the loop helps avoid an implicit mask.
Rewriting the _packedAddressData[to] = ... in assembly actually costs more gas.
Moving uint256 toMasked; after uint256 end = startTokenId + quantity; actually costs more gas.
Just letting it sit here.
May or may not decide to merge.
OpenSea Rinkeby is able to detect the events as per normal.
Saves 36 gas for the first mint and 28 gas per additional iteration (
28 / 1958 ≈ 1.4%
savings per additional iteration).The variables and statements have been carefully arranged to ensure that the compiler is as well behaved as possible. (actually, it can perform better than 100% handwritten Yul cuz Solidity provides high level semantics that can aid optimizations).
Before:
After:
Some trivia:
iszero(eq(tokenId, end))
is more efficient thanlt(tokenId, end)
because of how the compiler implicitly adds a
iszero
for thelt
, and removes theiszero
for theeq
.Moving the zero address check after the loop helps avoid an implicit mask.
Rewriting the
_packedAddressData[to] = ...
in assembly actually costs more gas.Moving
uint256 toMasked;
afteruint256 end = startTokenId + quantity;
actually costs more gas.