Omniscia AllianceBlock Audit
DiamondLoupeFacet Code Style Findings
DiamondLoupeFacet Code Style Findings
DLF-01C: Loop Iterator Optimizations
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | DiamondLoupeFacet.sol:L29, L31, L39, L82, L84, L111, L113, L121 |
Description:
The linked for
loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X
).
Example:
contracts/facets/DiamondLoupeFacet.sol
29for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) {
Recommendation:
We advise the increment / decrement operations to be performed in an unchecked
code block as the last statement within each for
loop to optimize their execution cost.
Alleviation (54fd570de24631ca65a7cea022aebe43225a08c7):
The referenced loop iterator increment statements have been relocated at the end of each respective for
loop's body and have been unwrapped in an unchecked
code block, optimizing their gas cost.