Replies: 1 comment 1 reply
-
Correct - we can use "we can use unsafe_add()" -> no since it's always possible that someone changes the upper bound of "The comments needs to move before L546" -> no since the comment relates to the line that could potentially overflow (in this case an |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sorry for nitpick, I was going through the code and spotted gas saving optimization.
https://github.com/pcaversaccio/snekmate/blob/main/src/tokens/ERC721.vy#L546
Using token_id for incrementing self._counter saves gas, even though self._counter qualifies for warm touch,
reading state variable is costly than reading from local variable.
We can further optimize the code. As per the comment in next line, we can use unsafe_add() since we don't expect token_ids to exceed 2**256. However testSafeMintOverflow() fails if we add unsafe_add.
Also, the comments needs to move before L546 ?
I have a draft PR at jaglinux@4ea3521
Beta Was this translation helpful? Give feedback.
All reactions