Omniscia Alliance Block Audit

DiamondLoupeFacet Code Style Findings

DiamondLoupeFacet Code Style Findings

DLF-01C: Redundant Variable Assignment

Description:

The linked variable assignment is redundant as the loop will reset the memory state.

Example:

contracts/facets/DiamondLoupeFacet.sol
38bool continueLoop = false;
39for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {
40 if (facets_[facetIndex].facetAddress == facetAddress_) {
41 facets_[facetIndex].functionSelectors[numFacetSelectors[facetIndex]] = selector;
42 // probably will never have more than 256 functions from one facet contract
43 require(numFacetSelectors[facetIndex] < 255);
44 numFacetSelectors[facetIndex]++;
45 continueLoop = true;
46 break;
47 }
48}
49if (continueLoop) {
50 continueLoop = false;
51 continue;
52}

Recommendation:

We advise it to be omitted for gas purposes.

Alleviation:

The redundant variable assignment was properly omitted in both linked segments.