Skip to content

Commit

Permalink
Revert "core/vm: performance tweak of OpCode.String() (ethereum#28453
Browse files Browse the repository at this point in the history
…)"

This reverts commit 0622724.
  • Loading branch information
devopsbo3 authored Nov 10, 2023
1 parent 00b1057 commit 0cead1f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/vm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ const (
SELFDESTRUCT OpCode = 0xff
)

var opCodeToString = [256]string{
// Since the opcodes aren't all in order we can't use a regular slice.
var opCodeToString = map[OpCode]string{
// 0x0 range - arithmetic ops.
STOP: "STOP",
ADD: "ADD",
Expand Down Expand Up @@ -398,10 +399,12 @@ var opCodeToString = [256]string{
}

func (op OpCode) String() string {
if s := opCodeToString[op]; s != "" {
return s
str := opCodeToString[op]
if len(str) == 0 {
return fmt.Sprintf("opcode %#x not defined", int(op))
}
return fmt.Sprintf("opcode %#x not defined", int(op))

return str
}

var stringToOp = map[string]OpCode{
Expand Down

0 comments on commit 0cead1f

Please sign in to comment.