Closed KamaDeFi closed 2 years ago
Perhaps we can add a short comment in the code on why we're duplicating @Vectorized
I've thought about this some more, and if I understand correctly, the only saving in gas here is to avoid only one extra call of tokenId := add(tokenId, 1)
and iszero(eq(tokenId, end))
. That doesn't seem to have the massive gas-saving benefit that is worth duplicating code in my opinion.
Examples:
Scenario 1, quantity = 1
Existing code would call:
log4
let tokenId := add(startTokenId, 1)
iszero(eq(tokenId, end))
But the new code would call:
let tokenId := startTokenId
iszero(eq(tokenId, end))
log4
tokenId := add(tokenId, 1)
iszero(eq(tokenId, end))
Scenario 2, quantity = 2
Existing code would call:
log4
let tokenId := add(startTokenId, 1)
iszero(eq(tokenId, end))
log4
tokenId := add(tokenId, 1)
iszero(eq(tokenId, end))
But the new code would call:
let tokenId := startTokenId
iszero(eq(tokenId, end))
log4
tokenId := add(tokenId, 1)
iszero(eq(tokenId, end))
log4
tokenId := add(tokenId, 1)
iszero(eq(tokenId, end))
The events are duplicated on purpose to save gas.