Omniscia AllianceBlock Audit
UtilityFacet Code Style Findings
UtilityFacet Code Style Findings
UFT-01C: Loop Iterator Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | UtilityFacet.sol:L22 |
Description:
The linked for
loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X
).
Example:
contracts/facets/UtilityFacet.sol
22for (uint256 i = 0; i < subroutines.length; i++) {
Recommendation:
We advise the increment / decrement operation to be performed in an unchecked
code block as the last statement within the for
loop to optimize its execution cost.
Alleviation (54fd570de24631ca65a7cea022aebe43225a08c7):
The referenced loop iterator's increment statement has been relocated at the end of the for
loop's body and has been unwrapped in an unchecked
code block, optimizing its gas cost.