Skip to content

Commit

Permalink
Comments on the assembly mint loop (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized authored Aug 7, 2022
1 parent 3d7e5ee commit 002562b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/ERC721A.sol
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ contract ERC721A is IERC721A {
uint256 end = startTokenId + quantity;

// Use assembly to loop and emit the `Transfer` event for gas savings.
// The duplicated `log4` removes an extra check and reduces stack juggling.
// The assembly, together with the surrounding Solidity code, have been
// delicately arranged to nudge the compiler into producing optimized opcodes.
assembly {
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
toMasked := and(to, _BITMASK_ADDRESS)
Expand Down

0 comments on commit 002562b

Please sign in to comment.