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

This reverts commit 0622724082.
This commit is contained in:
devopsbo3 2023-11-10 12:27:53 -06:00 committed by GitHub
parent b2b7ffdb0d
commit 5be5a95818

View file

@ -224,7 +224,8 @@ const (
SELFDESTRUCT OpCode = 0xff 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. // 0x0 range - arithmetic ops.
STOP: "STOP", STOP: "STOP",
ADD: "ADD", ADD: "ADD",
@ -398,12 +399,14 @@ var opCodeToString = [256]string{
} }
func (op OpCode) String() string { func (op OpCode) String() string {
if s := opCodeToString[op]; s != "" { str := opCodeToString[op]
return s 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{ var stringToOp = map[string]OpCode{
"STOP": STOP, "STOP": STOP,
"ADD": ADD, "ADD": ADD,