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

1 stars 0 forks source link

Gas Optimizations #223

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L43 https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L70 https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L93

In above mentioned line of codes, using the pre increment will save some gas.

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L399 https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L411 https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L413

In above mentioned line of codes, block.timestamp can be get one time and assigned to a new variable and that variable can be used in other places.

HardlyDifficult commented 2 years ago

Yes, pre increment can save a tiny amount of gas. This is a common report which can be found with static analysis. I don't believe caching block.timestamp would be helpful.

This warden made a number of low quality reports, the sponsor's time should be respected. Therefore I'm closing this report as invalid.