Open code423n4 opened 2 years ago
Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 627)
File: contracts\src\PuttyV2.sol (Line 637)
File: contracts\src\PuttyV2.sol (Line 647)
File: contracts\src\PuttyV2.sol (Line 658)
<ARRAY>.LENGTH
Even memory arrays incur the overhead of bit tests and bit shifts to calculate the array length
File: contracts\src\PuttyV2.sol (Line 611)
File: contracts\src\PuttyV2.sol (Line 89)
File: contracts\src\PuttyV2.sol (Line 95)
BOOL
refer to this.
File: contracts\src\PuttyV2.sol (Line 143)
File: contracts\src\PuttyV2.sol (Line 155)
REVERT()/REQUIRE()
File: contracts\src\PuttyV2.sol (Line 329)
File: contracts\src\PuttyV2.sol (Line 405)
++I
File: contracts\src\PuttyV2.sol (Line 556)
File: contracts\src\PuttyV2.sol (Line 594)
> 0
!= 0
REQUIRE()
File: contracts\src\PuttyV2.sol (Line 598)
File: contracts\src\PuttyV2.sol (Line 599)
CallData
floorAssetTokenIds
calldata
1. ++I COSTS LESS GAS THAN ++I, ESPECIALLY WHEN IT’S USED IN FOR-LOOPS (--I/I-- TOO)
Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 627)
File: contracts\src\PuttyV2.sol (Line 637)
2. AVOIDING INITIALIZATION OF LOOP INDEX CAN SAVE A LITTLE GAS
Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 647)
File: contracts\src\PuttyV2.sol (Line 658)
3.
<ARRAY>.LENGTH
SHOULD NOT BE LOOKED UP IN EVERY LOOP OF A FOR-LOOPEven memory arrays incur the overhead of bit tests and bit shifts to calculate the array length
Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 611)
File: contracts\src\PuttyV2.sol (Line 658)
4. EXPRESSIONS FOR CONSTANT VALUES SUCH AS A CALL TO KECCAK256(), SHOULD USE IMMUTABLE RATHER THAN CONSTANT
Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 89)
File: contracts\src\PuttyV2.sol (Line 95)
5. USING
BOOL
S FOR STORAGE INCURS OVERHEADrefer to this.
Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 143)
File: contracts\src\PuttyV2.sol (Line 155)
6. USE CUSTOM ERRORS RATHER THAN
REVERT()/REQUIRE()
STRINGS TO SAVE DEPLOYMENT GASExamples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 329)
File: contracts\src\PuttyV2.sol (Line 405)
7.
++I
COSTS LESS GAS THAN++I
, ESPECIALLY WHEN IT’S USED IN FOR-LOOPS (--I/I-- TOO)Examples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 556)
File: contracts\src\PuttyV2.sol (Line 594)
8. USING
> 0
COSTS MORE GAS THAN!= 0
WHEN USED ON A UINT IN AREQUIRE()
STATEMENTExamples of this issue in the codebase:
File: contracts\src\PuttyV2.sol (Line 598)
File: contracts\src\PuttyV2.sol (Line 599)
9. USE
CallData
INSTEAD OF MEMORYExamples of this issue in the codebase:
floorAssetTokenIds
can be changed tocalldata
(Line 271)