@@ -54,7 +54,7 @@ library LibDiamond {
5454 function _diamondCut (FacetCut[] memory _facetCuts , address _init , bytes memory _calldata ) internal {
5555 uint256 facetCutsLength = _facetCuts.length ;
5656 if (facetCutsLength == 0 ) revert NoFacetsInDiamondCut ();
57- for (uint256 facetIndex; facetIndex < facetCutsLength;) {
57+ for (uint256 facetIndex; facetIndex < facetCutsLength; ++ facetIndex ) {
5858 FacetCutAction action = _facetCuts[facetIndex].action;
5959 if (action == FacetCutAction.Add) {
6060 _addFunctions (_facetCuts[facetIndex].facetAddress, _facetCuts[facetIndex].functionSelectors);
@@ -65,9 +65,6 @@ library LibDiamond {
6565 } else {
6666 revert IncorrectFacetCutAction (uint8 (action));
6767 }
68- unchecked {
69- ++ facetIndex;
70- }
7168 }
7269 emit DiamondCut (_facetCuts, _init, _calldata);
7370 _initializeDiamondCut (_init, _calldata);
@@ -86,15 +83,12 @@ library LibDiamond {
8683 if (selectorPosition == 0 ) {
8784 _addFacet (ds, _facetAddress);
8885 }
89- for (uint256 selectorIndex; selectorIndex < functionSelectorsLength;) {
86+ for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++ selectorIndex ) {
9087 bytes4 selector = _functionSelectors[selectorIndex];
9188 address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress;
9289 if (oldFacetAddress != address (0 )) revert CannotAddFunctionToDiamondThatAlreadyExists (selector);
9390 _addFunction (ds, selector, selectorPosition, _facetAddress);
94- selectorPosition++ ;
95- unchecked {
96- ++ selectorIndex;
97- }
91+ ++ selectorPosition;
9892 }
9993 }
10094
@@ -111,18 +105,15 @@ library LibDiamond {
111105 if (selectorPosition == 0 ) {
112106 _addFacet (ds, _facetAddress);
113107 }
114- for (uint256 selectorIndex; selectorIndex < functionSelectorsLength;) {
108+ for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++ selectorIndex ) {
115109 bytes4 selector = _functionSelectors[selectorIndex];
116110 address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress;
117111 if (oldFacetAddress == _facetAddress) {
118112 revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet (selector);
119113 }
120114 _removeFunction (ds, oldFacetAddress, selector);
121115 _addFunction (ds, selector, selectorPosition, _facetAddress);
122- selectorPosition++ ;
123- unchecked {
124- ++ selectorIndex;
125- }
116+ ++ selectorPosition;
126117 }
127118 }
128119
@@ -134,13 +125,10 @@ library LibDiamond {
134125 if (_facetAddress != address (0 )) revert RemoveFacetAddressMustBeZeroAddress (_facetAddress);
135126 if (functionSelectorsLength == 0 ) revert NoSelectorsProvidedForFacetForCut (_facetAddress);
136127 DiamondStorage storage ds = _diamondStorage ();
137- for (uint256 selectorIndex; selectorIndex < functionSelectorsLength;) {
128+ for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++ selectorIndex ) {
138129 bytes4 selector = _functionSelectors[selectorIndex];
139130 address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress;
140131 _removeFunction (ds, oldFacetAddress, selector);
141- unchecked {
142- ++ selectorIndex;
143- }
144132 }
145133 }
146134
0 commit comments