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

Gas Optimizations #247

Open
code423n4 opened this issue Jul 8, 2022 · 0 comments
Open

Gas Optimizations #247

code423n4 opened this issue Jul 8, 2022 · 0 comments
Labels

Comments

@code423n4
Copy link
Contributor

[G-1]- .LENGTH SHOULD NOT BE LOOKED UP IN EVERY LOOP OF A FOR-LOOP :

The array length used inside a loop for incrementing i must not be looked up in every iteration

File: juice-contracts-v2-code4rena/contracts/JBDirectory.sol

line 167 : for (uint256 _i; _i < _terminalsOf[_projectId].length; _i++)

[G-2]- += COSTS MORE GAS THAN = + FOR STATE VARIABLES :

File: juice-contracts-v2-code4rena/contracts/JBTokenStore.sol

line 409 : unclaimedBalanceOf[_holder][_projectId] = unclaimedBalanceOf[_holder][_projectId] - _amount;
line 412 : unclaimedTotalSupplyOf[_projectId] = unclaimedTotalSupplyOf[_projectId] - _amount;
line 451 : unclaimedBalanceOf[_recipient][_projectId] = unclaimedBalanceOf[_recipient][_projectId] + _amount;

[G-3]- READING MEMORY VARIABLE INSTEAD OF STATE VARIABLE INSIDE A FOR LOOP :

File: juice-contracts-v2-code4rena/contracts/JBDirectory.sol

line 168 : if (_terminalsOf[_projectId][_i] == _terminal) return true;

[G-4]- USE OF ++i COST LESS GAS THAN i++ IN FOR LOOPS :

File: juice-contracts-v2-code4rena/contracts/JBDirectory.sol

line 167 : for (uint256 _i; _i < _terminalsOf[_projectId].length; _i++)

File: juice-contracts-v2-code4rena/contracts/JBOperatorStore.sol

line 85 : for (uint256 _i = 0; _i < _permissionIndexes.length; _i++);

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jul 8, 2022
code423n4 added a commit that referenced this issue Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants