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

core/vm: performance tweak of OpCode.String() #28453

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

lmittmann
Copy link
Contributor

Small change that improves the performance of OpCode.String() by changing:

- var opCodeToString = map[OpCode]string{
+ var opCodeToString = [256]string{

// Since the opcodes aren't all in order we can't use a regular slice.

Yes, but we can use an array and define opcodes using a key-value-pair as one would do in a map (so order still does not matter).

@holiman holiman changed the title core/vm: Performance Tweak of OpCode.String() core/vm: performance tweak of OpCode.String() Nov 1, 2023
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

neat!

@karalabe karalabe added this to the 1.13.5 milestone Nov 2, 2023
@karalabe karalabe merged commit a3be381 into ethereum:master Nov 2, 2023
2 checks passed
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
make `opCodeToString` a `[256]string` array

Co-authored-by: lmittmann <[email protected]>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Dergarcon pushed a commit to specialmechanisms/mev-geth-0x2mev that referenced this pull request Jan 31, 2024
make `opCodeToString` a `[256]string` array

Co-authored-by: lmittmann <[email protected]>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Mar 1, 2024
make `opCodeToString` a `[256]string` array

Co-authored-by: lmittmann <[email protected]>
colinlyguo pushed a commit to scroll-tech/go-ethereum that referenced this pull request Oct 31, 2024
make `opCodeToString` a `[256]string` array

Co-authored-by: lmittmann <[email protected]>
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.

4 participants