code-423n4 / 2022-09-quickswap-findings

0 stars 0 forks source link

Gas Optimizations #322

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Unnecessary require The check that owner != _owner in AlgebraFactory.sol#L78 is unnecessary. If the check is triggered, the function simply does nothing. It is better to save gas for the intended calls than for a pointless call. Similarly for AlgebraFactory.sol#L85 and AlgebraFactory.sol#L92.

 

Pre-incrementing is cheaper than post-incrementing Consider replacing e.g. i++ with ++i.

Instance: https://github.com/code-423n4/2022-09-quickswap/blob/15ea643c85ed936a92d2676a7aabf739b210af39/src/core/contracts/libraries/DataStorage.sol#L307

 

Pre-compute .length before repeated usage, especially in loops

Instances: https://github.com/code-423n4/2022-09-quickswap/blob/15ea643c85ed936a92d2676a7aabf739b210af39/src/core/contracts/libraries/DataStorage.sol#L294-L297 https://github.com/code-423n4/2022-09-quickswap/blob/15ea643c85ed936a92d2676a7aabf739b210af39/src/core/contracts/libraries/DataStorage.sol#L307

0xean commented 2 years ago

closing, LQ.