tokamak-network / Tms-contract

GNU General Public License v3.0
0 stars 1 forks source link

Let's reorder the if statements for gas optimization #9

Closed usgeeus closed 2 months ago

usgeeus commented 2 months ago

Describe the bug We can save gas by reordering the if statements

Lines of Codes https://github.com/tokamak-network/Tms-contract/blob/31a33830d7840ef742a24d1be3b299d6a1a05c07/contracts/MultiSender.sol#L54-L61

Configuration

Impact When amounts[i] is zero and _recipients[i] is address(0), This results in an unnecessary plus-zero operation _failedAmount += 0

Recommendation Reverse the order.

usgeeus commented 2 months ago

Solved