Gas: > 0
is less efficient than != 0
for unsigned integers (with proof)
#133
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
Handle
Dravee
Vulnerability details
Impact
!= 0
costs less gas compared to> 0
for unsigned integers inrequire
statements with the optimizer enabled (6 gas)Proof: While it may seem that
> 0
is cheaper than!=
, this is only true without the optimizer enabled and outside a require statement. If you enable the optimizer at 10k AND you're in arequire
statement, this will save gas. You can see this tweet for more proofs: https://twitter.com/gzeon/status/1485428085885640706Proof of Concept
> 0
in require statements are used in the following location(s):Tools Used
VS Code
Recommended Mitigation Steps
Change
> 0
with!= 0
in require statements. Also, enable the Optimizer.The text was updated successfully, but these errors were encountered: