You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[G-02] The increment in for loop post condition can be made unchecked
The solidity compiler will apply arithmetic checks for the increment step during for loops. This can be disabled since the value being incremented won't surpass the upper bound that's checked on the break condition.
[G-01] ++variable costs less gas than variable++, especially in for loops
Saves about 5 gas per loop.
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Project.sol
[G-02] The increment in for loop post condition can be made unchecked
The solidity compiler will apply arithmetic checks for the increment step during for loops. This can be disabled since the value being incremented won't surpass the upper bound that's checked on the break condition.
Adding uncheck can save 30-40 gas per loop.
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Project.sol
[G-03] Array.length should not be computed on every interation during a loop
Instead of computing array.length for every iteration, the value for array.length should be cached before the loop to save gas.
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Project.sol
[G-04] It costs more gas to initialize variables to zero than to let the default of zero be applied
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Project.sol
[G-05] != costs less gas than > in conditional contexts for uints
Saves about 6 gas.
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Project.sol
[G-06] Use custom errors rather than revert()/require() to save gas
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Project.sol
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Community.sol
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/HomeFi.sol
The text was updated successfully, but these errors were encountered: