Gas Optimizations #220
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
FOR-LOOPS:
++i
COSTS LESS GAS THANi++
++i
costs less gas thanI++
for unsigned integer, it costs 5 gas per iteration.And also i suggest to change
uint256 i=0
touint256 i
. The default value of variable is0
for unsigned integer. So explicitly initializing it with its default value is an anti-pattern and wastes gas.for (uint256 i = 0; i < rewardTokensLength; i++) {
I suggest you to change those line into:
for (uint256 i; i < rewardTokensLength; i++){
This already done here:
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L306
for (uint256 i; i < rewardTokensLength; i++) {
Instance include:
https://github.com/code-423n4/2022-05-aura/blob/main/convex-platform/contracts/contracts/Booster.sol#L222
https://github.com/code-423n4/2022-05-aura/blob/main/convex-platform/contracts/contracts/Booster.sol#L379
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L174
The text was updated successfully, but these errors were encountered: