\<VAR>++ OR \<VAR> += 1 TO ++\<VAR> ALSO USE UNCHECKED FOR OPERATIONS NOT EXPECTED TO OVERFLOW
When the value of the post-loop increment/decrement is not stored or used in any calculations, the prefix increment/decrement operators (++i/--i) cost less gas PER LOOP than the postfix increment/decrement operators (i++/i--)
Gas Report
\<VAR>++ OR \<VAR> += 1 TO ++\<VAR> ALSO USE UNCHECKED FOR OPERATIONS NOT EXPECTED TO OVERFLOW
When the value of the post-loop increment/decrement is not stored or used in any calculations, the prefix increment/decrement operators (
++i
/--i
) cost less gas PER LOOP than the postfix increment/decrement operators (i++
/i--
)Use
++i
rather thani++
to save gasInstances include
i++ to ++i:
i++ to ++i and add unchecked:
CACHING LENGTH ON FOR
Cache the lenth in the for loops
zeroswap/contracts/uniswapv2/UniswapV2Oracle.sol: L83 cache the granularity
zeroswap/contracts/uniswapv2/UniswapV2Router02.sol: L214, L323 cache the
path.lenght-1
zeroswap/contracts/mocks/ComplexRewarderTime.sol: L157 zeroswap/contracts/uniswapv2/UniswapV2Oracle.sol: L83
State variables can be constant;
MasterChef.sol
MasterChef.sol#L59
MasterChef.sol#L63
MasterChef.sol#L65
MasterChef.sol#L77
Save gas avoiding initialize variables with 0
MasterChef.sol#L75
This will save you gas: