TangibleTNFT / baskets-foundry

baskets-foundry
1 stars 0 forks source link

[BMR-02C] Inefficient Loop Limit Evaluation #50

Closed chasebrownn closed 7 months ago

chasebrownn commented 7 months ago

BMR-02C: Inefficient Loop Limit Evaluation

Type Severity Location
Gas Optimization BasketManager.sol:L321

Description:

The linked for loop evaluates its limit inefficiently on each iteration.

Example:

for (uint256 i; i < baskets.length;) {

Recommendation:

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

chasebrownn commented 7 months ago

Fixed