code-423n4 / 2022-06-nested-findings

0 stars 1 forks source link

Gas Optimizations #22

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Variables: No need to explicitly initialize variables with default values

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.

We can use uint number; instead of uint number = 0;

Instance Includes:

contracts/NestedRecords.sol:71:            uint256 tokenIndex = 0;

Recommendation:

I suggest removing explicit initializations for default values.

Yashiru commented 2 years ago

Variables: No need to explicitly initialize variables with default values (Duplicated)

Duplicated of #2 at For loop optimizaion

JeeberC4 commented 2 years ago

Warden submitted multiple Gas Optimizations. Will not be judged.