Gas Optimizations #61
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
G-1 COMPARISONS WITH ZERO FOR UNSIGNED INTEGERS
>0
is less gas efficient than!0
only if you enable optimizer and you're in a require statement.https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/BkdLocker.sol#:~:text=require(amount%20%3E%200%2C%20Error.INVALID_AMOUNT)%3B
G-2 An length should be cached to save gas in for-loops
Some of the for-loops in other contracts already have been doing this but the one below hasn't.
https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/StakerVault.sol#:~:text=for%20(uint256%20i%3B%20i%20%3C%20actions.length%3B%20i%20%3D%20i.uncheckedInc())%20%7B
The text was updated successfully, but these errors were encountered: