diff --git a/core/asm/compiler.go b/core/asm/compiler.go index ce2d23abd0ba..4c2af78c8162 100644 --- a/core/asm/compiler.go +++ b/core/asm/compiler.go @@ -17,6 +17,7 @@ package asm import ( + "encoding/hex" "fmt" "math/big" "os" @@ -106,12 +107,13 @@ func (c *Compiler) Compile() (string, []error) { // turn the binary to hex var bin strings.Builder + bin.Grow(len(c.binary)) for _, v := range c.binary { switch v := v.(type) { case vm.OpCode: - bin.WriteString(fmt.Sprintf("%x", []byte{byte(v)})) + bin.WriteString(hex.EncodeToString([]byte{byte(v)})) case []byte: - bin.WriteString(fmt.Sprintf("%x", v)) + bin.WriteString(hex.EncodeToString(v)) } } return bin.String(), errors