When checking whether a value is equal to zero, using the construction var != 0 is costs less gas than using var > 0. Note that this is true only when the comparison occurs in a conditional context and the Solidity compiler is using the Optimizer.
For more information, please consult the following resources:
Gas Report
Replace strict greater-than-zero operation (> 0) with does-not-equal-zero (!= 0) operation
When checking whether a value is equal to zero, using the construction
var != 0
is costs less gas than usingvar > 0
. Note that this is true only when the comparison occurs in a conditional context and the Solidity compiler is using the Optimizer.For more information, please consult the following resources:
Twitter discussion detailing the gas costs of != 0 vs > 0 in require() calls
Solidity Compiler: Optimizer options
The following lines of code are affected: