Omniscia Alliance Block Audit
LiquidityMiningCampaign Code Style Findings
LiquidityMiningCampaign Code Style Findings
LMC-01C: Array Lookup Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | LiquidityMiningCampaign.sol:L198, L199, L200 |
Description:
The _lockSchemes[i]
entry is redundantly looked up thrice when the inner if
block's condition is satisfied.
Example:
contracts/LiquidityMiningCampaign.sol
198if(!lockSchemesExist[_lockSchemes[i]]) {199 lockSchemes.push(_lockSchemes[i]);200 lockSchemesExist[_lockSchemes[i]] = true;201}
Recommendation:
We advise the result of _lockSchemes[i]
to be cached to an in-memory address
variable that is consequently utilized, reducing the gas cost of the function.
Alleviation:
The address
of the array lookup is now properly cached in memory and consequently utilized thrice.