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

chore(interpreter): use let else #629

Merged
merged 2 commits into from Aug 23, 2023
Merged

Conversation

DaniPopes
Copy link
Collaborator

@DaniPopes DaniPopes commented Aug 22, 2023

Split off from #582

And macros style changes.

Improves readability. MSRV for this feature is 1.65 but I see it's already present in revm.

Copy link
Collaborator

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine but defer to dragan for the stylistical choice , know seitz doesn't like let else

Comment on lines 44 to 43
Some(gas_used) => gas!($interp, gas_used),
None => {
Some(gas_used) if $interp.gas.record_cost(gas_used) => {}
_ => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit any reason to not use the macro

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would duplicate the assign/return on both branches, doesn't really matter since compiler probably optimizes that anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this one, I slightly vary on the fn call side-effect inside if, and second reason is that gas! is used everywhere so it converges to one place

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understandable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
)*
)
($interp:expr, $($x:expr),* $(,)?) => ($(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this now lets you push multiple values? or what is the new $(,)? for?

Copy link
Collaborator Author

@DaniPopes DaniPopes Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just allows trailing comma. Sometimes rustfmt will add it and then parsing fails because it is not expected in the macro.

@DaniPopes
Copy link
Collaborator Author

It also avoids unwrap, let else was "invented" for this exact use case.

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit for gas! macro. Other things lgtm!

@rakita rakita merged commit 84a5e97 into bluealloy:main Aug 23, 2023
7 checks passed
@DaniPopes DaniPopes deleted the ir-letsome branch August 23, 2023 13:41
mikelodder7 pushed a commit to LIT-Protocol/revm that referenced this pull request Sep 12, 2023
* chore(interpreter): use `let else`

* use gas macro
Evalir pushed a commit to Evalir/revm that referenced this pull request Sep 14, 2023
* chore(interpreter): use `let else`

* use gas macro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants