Skip to content

Code and gas optimizations for v1#84

Merged
spengrah merged 5 commits intodevelopfrom
optimize-v1
Jan 16, 2023
Merged

Code and gas optimizations for v1#84
spengrah merged 5 commits intodevelopfrom
optimize-v1

Conversation

@spengrah
Copy link
Copy Markdown
Member

@spengrah spengrah commented Jan 12, 2023

This PR makes several simple / low-hanging fruit gas optimizations, the biggest of which is moving the hat supply tracker into the Hat struct (saving ~20k gas for each hat mint).

@spengrah spengrah requested a review from nintynick January 13, 2023 20:43
@spengrah spengrah marked this pull request as ready for review January 13, 2023 20:52

unchecked {
// should not underflow given NotHatWearer check above
--_balanceOf[_from][_hatId];
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be both safer and cheaper to set these balancesOf values to 0 and 1, respectively

returns (bool)
{
return (balanceOf(_user, _hatId) >= 1);
return (balanceOf(_user, _hatId) > 0);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is > or == cheaper?

Copy link
Copy Markdown
Member

@nintynick nintynick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed in pairing with @slgraham just now - LGTM

@spengrah spengrah merged commit c756baa into develop Jan 16, 2023
@spengrah spengrah deleted the optimize-v1 branch January 16, 2023 20:47
@spengrah spengrah mentioned this pull request Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants