wise-foundation / lending-audit

5 stars 4 forks source link

[FMR-02C] Inefficient Loop Limit Evaluations #40

Open vm06007 opened 11 months ago

vm06007 commented 11 months ago

FMR-02C: Inefficient Loop Limit Evaluations

Type Severity Location
Gas Optimization FeeManager.sol:L160, L416

Description:

The linked for loops evaluate their limit inefficiently on each iteration.

Example:

for (uint8 i = 0; i < getPoolTokenAddressesLength(); ++i) {

Recommendation:

We advise the statements within the for loop limits to be relocated outside to a local variable declaration that is consequently utilized for the evaluations to significantly reduce the codebase's gas cost. We should note the same optimization is applicable for storage reads present in those limits as they are newly read on each iteration (i.e. length members of arrays in storage).

vm06007 commented 11 months ago

Resolved in: https://github.com/wise-foundation/lending-audit/pull/39