Platform: Code4rena
Start Date: 15/06/2022
Pot Size: $35,000 USDC
Total HM: 1
Participants: 36
Period: 3 days
Judge: Jack the Pug
Total Solo HM: 1
Id: 137
League: ETH
Rank: 35/36
Findings: 1
Award: $34.72
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xKitsune, 0xNazgul, 0xkatana, Chom, ElKu, JC, Meera, MiloTruck, Picodes, PierrickGT, SooYa, TerrierLover, UnusualTurtle, Waze, _Adam, asutorufos, c3phas, delfin454000, fatherOfBlocks, joestakey, minhquanym, oyc_109, robee, sach1r0, simon135
34.7201 USDC - $34.72
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:
for (uint256 i = 0; i < numIterations; ++i) {
should be replaced with
for (uint256 i; i < numIterations; ++i) {
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
#0 - Yashiru
2022-06-24T15:49:14Z
Duplicated of #2 at For loop optimizaion
Duplicated of #2 at For loop optimizaion