Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ReservesSetupHelper.sol: Optimized Gas #904

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0xScratch
Copy link

Types of changes made:

1st - Struct Packing - Aligning booleans with the address in order to decrease the slots which kinds of save gas. Refer this -> https://dev.to/javier123454321/solidity-gas-optimizations-pt-3-packing-structs-23f4

2nd - uint256 i = 0; to uint256 i - This change too saves some gas cuz the default value of all unsigned integers is 0. Thus, I find no need to initialize it

3rd - using unchecked - After the Solidity 0.8 version, Solidity compilers started using overflow/underflow checks which is gas costly. But I find that there's no chance of any underflow/overflow in this loop, so unchecked can be used in this purpose. (Tho, I still suggest to take a brief look into this change)

4th - i++ to ++i - Saves gas, just make sure it doesn't messes up with the code's logic.

Refer this for 2nd, 3rd and 4th change -> https://gist.github.com/grGred/9bab8b9bad0cd42fc23d4e31e7347144#for-loops-improvement

@height
Copy link

height bot commented Sep 13, 2023

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

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.

1 participant