kaden
kaden
for every `uint > 0` check, replace with `uint != 0` to save about 44 gas per call see: https://github.com/KadenZipfel/gas-optimizations/blob/main/gas-saving-patterns/optimal-comparison-operator.md
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) { ... }...
for technical gas saving patterns, e.g. https://github.com/KadenZipfel/gas-optimizations/blob/main/gas-saving-patterns/optimal-comparison-operator.md, in which the pattern works because of a solidity compilation gotcha, the mechanism in which gas is saved should be better detailed, e.g....
some things that can be added: - use selfbalance opcode instead of address(this).balance - use iszero opcode instead of if(x) - https://twitter.com/clemlak/status/1521973218864771073?s=20&t=Bw97nieWjOAs4O2x2Kr8Tg - etc
in general, do while loops are cheaper than for loops. as long as the loop is must run at least once, do while is preferred over for loops
we should make sure we have both: - clear examples, and - before and after gas benchmarks for every gas saving pattern