mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
make opCodeToString a [256]string array
This commit is contained in:
parent
f4ac548619
commit
d82fc06964
1 changed files with 4 additions and 7 deletions
|
|
@ -224,8 +224,7 @@ const (
|
||||||
SELFDESTRUCT OpCode = 0xff
|
SELFDESTRUCT OpCode = 0xff
|
||||||
)
|
)
|
||||||
|
|
||||||
// Since the opcodes aren't all in order we can't use a regular slice.
|
var opCodeToString = [256]string{
|
||||||
var opCodeToString = map[OpCode]string{
|
|
||||||
// 0x0 range - arithmetic ops.
|
// 0x0 range - arithmetic ops.
|
||||||
STOP: "STOP",
|
STOP: "STOP",
|
||||||
ADD: "ADD",
|
ADD: "ADD",
|
||||||
|
|
@ -399,12 +398,10 @@ var opCodeToString = map[OpCode]string{
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op OpCode) String() string {
|
func (op OpCode) String() string {
|
||||||
str := opCodeToString[op]
|
if s := opCodeToString[op]; s != "" {
|
||||||
if len(str) == 0 {
|
return s
|
||||||
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{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue