code-423n4 / 2022-07-juicebox-findings

0 stars 0 forks source link

Gas Optimizations #119

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

JBTokenStore.sol line 242 Short Circuiting optimization:

The order of the functions inside the if statement in line 242:

if (_token == IJBToken(address(0)) && requireClaimFor[_projectId])

can be switched to:

if (requireClaimFor[_projectId] && _token == IJBToken(address(0)))

for optimal gas usage because requireClaimFor is more probable to be FALSE hence second one won’t be executed and hence save you gas.

simon-something commented 2 years ago

Indeed, good catch!