Gas Optimizations #170
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
Gas Optimization
G-1 Comparisons:
In contract Aura.sol
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#:~:text=require(_amount%20%3E%200%2C%20%22Must%20mint%20something%22)%3B
G-2 Not needing to put False at isShutdown variable in AuraLocker.sol
In contract AuraLocker.sol
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#:~:text=bool%20public%20isShutdown%20%3D%20false%3B
You can just say bool public isShutdown; since the default value of bool is false.
G-3 Not needing to put false at initialised variable in AuraVestedEscrow.sol
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#:~:text=bool%20public%20initialised%20%3D%20false%3B
You can just say bool public initialised; as the default value of bool is false.
G-4 ++i cost less gas compared to i++
++i will cost less gas compared to i++ for uint especially useful for for loops where each iterations are about 5 gas.
Instances where:
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraClaimZap.sol#:~:text=curve%20LP%20pools-,for%20(uint256%20i%20%3D%200%3B%20i%20%3C%20rewardContracts.length%3B%20i,%7D,-//%20claim%20others/deposit
contracts/AuraLocker.sol:174:
contracts/AuraLocker.sol:306:
contracts/AuraLocker.sol:410:
contracts/AuraLocker.sol:696:
contracts/AuraLocker.sol:773:
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#:~:text=for%20(uint256%20i%20%3D%200%3B%20i%20%3C%20_recipient.length%3B%20i%2B%2B)%20%7B
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ExtraRewardsDistributor.sol#:~:text=for%20(uint256%20i%20%3D%20epochIndex%3B%20i%20%3C%20tokenEpochs%3B%20i%2B%2B)%20%7B
The text was updated successfully, but these errors were encountered: