gas-optimizations
gas-optimizations copied to clipboard
Separate conditions instead of combined conditions
Should add a section on this to https://github.com/kadenzipfel/gas-optimizations/blob/main/gas-saving-patterns/short-circuiting.md with this to leave the reader with a fully optimized statement
e.g. use
if (condition) {
if (anotherCondition) {
...
}
}
over
if (condition && anotherCondition) {...}
works for &&/||
What would ||
look like?
if (condition) { ... code x }
if (anotherCondition) { ... code x }
?
What would
||
look like?if (condition) { ... code x } if (anotherCondition) { ... code x }
?
yep! although makes me realize that the title would no longer properly apply