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

perf: make Stack::peek() return a reference #12

Closed
wants to merge 2 commits into from

Conversation

mooori
Copy link

@mooori mooori commented Jul 12, 2022

Modifies Stack::peek() to return a reference, i.e. &U256 instead of U256.
Since U256 derives Copy, call sites which need to own to the value returned
by peek may dereference to create a copy:

let x = *stack.peek(n);

Regarding Stack::peek_h256(): I think the H256 value must be constructed
inside the function and since it's not possible to return a reference to a local
variable, peek_h256 cannot return a reference &H256. If I'm missing
something here, please let me know!

The steps mentioned here under Reproduction can be taken to benchmark
this change in aurora-engine.

Ref: #448

@mooori
Copy link
Author

mooori commented Jul 12, 2022

This PR was made to save the code and result. Closing it since this change leads to a slight increase in NEAR gas usage:

thread 'tests::repro::repro_5bEgfRQ' panicked at 'assertion failed: `(left == right)`
  left: `706`,
 right: `707`', engine-tests/src/tests/repro.rs:146:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test tests::repro::repro_5bEgfRQ ... FAILED
thread 'tests::repro::repro_FRcorNv' panicked at 'assertion failed: `(left == right)`
  left: `197`,
 right: `198`', engine-tests/src/tests/repro.rs:146:5

@mooori mooori closed this Jul 12, 2022
aleksuss added a commit to aleksuss/sputnikvm that referenced this pull request Jul 3, 2024
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.

1 participant