Omniscia AllianceBlock Audit

LibDiamond Code Style Findings

LibDiamond Code Style Findings

LDD-01C: Loop Iterator Optimizations

Description:

The linked for loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X).

Example:

contracts/libraries/LibDiamond.sol
60for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {

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.