To optimize the for loop and make it consume less gas, i suggest to:
If a variable is not set/initialized, it is assumed to have the default value (0 for uint, false for bool, address(0) for address…). Explicitly initializing it with its default value is an anti-pattern and wastes gas.
Use ++i instead of i++, which is a cheaper operation (in this case there is no difference between i++ and ++i because we dont use the return value of this expression, which is the only difference between these two expression).
To optimize the for loop and make it consume less gas, i suggest to:
If a variable is not set/initialized, it is assumed to have the default value (0 for uint, false for bool, address(0) for address…). Explicitly initializing it with its default value is an anti-pattern and wastes gas.
Use ++i instead of i++, which is a cheaper operation (in this case there is no difference between i++ and ++i because we dont use the return value of this expression, which is the only difference between these two expression).
As an example:
should be replaced with
i suggest to change the code below: https://github.com/code-423n4/2022-06-nested/blob/main/contracts/abstracts/MixinOperatorResolver.sol#L37 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/abstracts/MixinOperatorResolver.sol#L56 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L40 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L60 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L75 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L124 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L136 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L196 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L256 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L315 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L333 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L369 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L412 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L651