The solidity compiler generates more code for “if (A && B) {}” than for “if (A) {if (B) {} }”.
Our experiment shows that switching from “if (A && B) {}” to “if (A) {if (B) {} }” can save gas fees.
There are two such cases:
|
if (reserveA == 0 && reserveB == 0) { |
|
if (reserveA == 0 && reserveB == 0) { |
Replacing
if (reserveA == 0 && reserveB == 0) {
with
if (reserveA == 0) {
if (reserveB == 0) {
can save gas fees and does not hurt code readability.