snapshot-labs / sx-evm

Core smart contracts of Snapshot X for EVM
https://docs.snapshotx.xyz
22 stars 12 forks source link

Gas savings with bool mapping #219

Closed pscott closed 1 year ago

pscott commented 1 year ago

In general, checking (in-)equality with zero is more efficient than any other value, since the compiler can avoid pushing any constant to the stack (it just uses the ISZERO opcode). Therefore, comparing a value with the TRUE constant is slightly less efficient than comparing it with FALSE (which is 0). The difference is tiny, though it also reduces bytecode size a bit.