@slippy-lint/slippy
Version:
A simple but powerful linter for Solidity
37 lines (27 loc) • 556 B
Markdown
# yul-prefer-iszero
Recommends using `iszero` instead of `eq` when comparing to the `0` literal in Yul code.
`iszero` is more readable, uses less gas, and results in smaller bytecode.
## Rule details
Examples of **incorrect** code for this rule:
```solidity
contract A {
function f(uint a) public {
uint x;
assembly {
x := eq(a, 0)
x := eq(0, a)
}
}
}
```
Examples of **correct** code for this rule:
```solidity
contract A {
function f(uint a) public {
uint x;
assembly {
x := iszero(a)
}
}
}
```