code-423n4 / 2022-01-timeswap-findings

2 stars 0 forks source link

loop index prefix instead of postfix #121

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

OriDabush

Vulnerability details

TimeswapPair.sol gas optimization

In line 359 in the TimeswapPair contract, you can prefix increment the loop index instead of postfix incrementing it. This change will save gas (it will prevent a useless operation in every iteration of the loop).

code before: for (uint256 i; i < ids.length; i++) { ... }

code after: for (uint256 i; i < ids.length; ++i) { ... }

amateur-dev commented 2 years ago

Similar issue reported over here #170; hence closing this