Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate conditions instead of combined conditions #12

Open
kadenzipfel opened this issue Jul 4, 2022 · 2 comments
Open

Separate conditions instead of combined conditions #12

kadenzipfel opened this issue Jul 4, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@kadenzipfel
Copy link
Owner

kadenzipfel commented Jul 4, 2022

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 &&/||

@kadenzipfel kadenzipfel added the enhancement New feature or request label Jul 4, 2022
@har777
Copy link

har777 commented Jul 4, 2022

What would || look like?

if (condition) { ... code x }
if (anotherCondition) { ... code x }

?

@kadenzipfel
Copy link
Owner Author

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

@kadenzipfel kadenzipfel changed the title Nested conditions instead of combined conditions Separate conditions instead of combined conditions Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants