Omniscia 0xPhase Audit

DiamondLoupeFacet Code Style Findings

DiamondLoupeFacet Code Style Findings

DLF-01C: Loop Iterator Optimization

TypeSeverityLocation
Gas OptimizationDiamondLoupeFacet.sol:L19

Description:

The linked for loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X).

Example:

diamond/Loupe/DiamondLoupeFacet.sol
19for (uint256 i; i < numFacets; 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 (3dd3d7bf0c2693b2f9c23bacedfa420393f7ea84):

All referenced loop iterators have been optimized as advised, removing their for declaration increment statement and instead performing it in an unchecked code block wherever needed (i.e. before a continue statement or at the end of the for loop's body).