code-423n4 / 2022-05-opensea-seaport-findings

1 stars 0 forks source link

Gas Optimizations #100

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

gas opt

object++ cost more then ++object . (same for --)

object+ 1 cost more then ++object .

The default value of uint is 0. So there is no need to set false at index variable. uint256 index = 0 cost more then uint256 index.

AmountDeriver.sol

line 44 -
uint256 extraCeiling = 0;
fix -
uint256 extraCeiling;

BasicOrderFulfiller.sol

line 948,1040 -
for (uint256 i = 0; i < totalAdditionalRecipients; )
fix -
for (uint256 i; i < totalAdditionalRecipients; )

CriteriaResolution

line 56,166,184,199 -
for (uint256 i = 0; i < totalCriteriaResolvers; ++i)
fix -
for (uint256 i; i < totalCriteriaResolvers; ++i)

OrderCombiner.sol

line 229 -
maximumFulfilled--;
fix -
--maximumFulfilled;
line 181,373,473,498,577,621,754 - 
for (uint256 i = 0; i < totalOrders; ++i)
fix - 
for (uint256 i; i < totalOrders; ++i)
line 247,291,598 - 
for (uint256 j = 0; j < offer.length; ++j)
line 470,751 -
uint256 totalFilteredExecutions = 0;
fix -
uint256 totalFilteredExecutions;
fix - 
for (uint256 j; j < offer.length; ++j)
line 490 -
totalFilteredExecutions += 1;
fix -
++totalFilteredExecutions;
line 515 - 
totalFilteredExecutions += 1;
fix -
++totalFilteredExecutions;
line 768 - 
totalFilteredExecutions += 1;
fix -
++totalFilteredExecutions;

OrderFulfiller.sol

line 217,306,471 -
for (uint256 i = 0; i < orderParameters.offer.length; )
fix -
for (uint256 i; i < orderParameters.offer.length; )

OrderValidator.sol

line 272,350 -
for (uint256 i = 0; i < totalOrders; )
fix -
for (uint256 i; i < totalOrders; )