Gas Optimizations #478
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Pre-incrementing is cheaper than post-incrementing
Consider replacing e.g.
i++
with++i
.Instances:
KernelUtils.sol: 49 64
Function not called by the contract can be
external
instead ofpublic
Instances:
Kernel.sol: 95 100 439 451
TRSRY.sol: 47 79
MINTR.sol: 20 25 33 37
RANGE.sol: 110 115 219
PRICE.sol: 108 113
VOTES.sol: 22 27 45 55
INSTR.sol: 23 28 37
Governance.sol: 145 151
Pre-compute
.length
before repeated usage, especially in loopsInstances:
Governance.sol#L278
observations.length
is already computed innumObservations
uint256 numObs = observations.length;
can be changed intouint256 numObs = numObservations;
as suggested by its preceding comment, because its length is already calculated during construction.PRICE.sol#L212
The text was updated successfully, but these errors were encountered: