Skip to content

Commit 4516e7d

Browse files
estensenavalonche
authored andcommitted
Improve performance of token compilation (ethereum#12)
1 parent 9daaece commit 4516e7d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/asm/compiler.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package asm
1818

1919
import (
20+
"encoding/hex"
2021
"fmt"
2122
"math/big"
2223
"os"
@@ -106,12 +107,13 @@ func (c *Compiler) Compile() (string, []error) {
106107

107108
// turn the binary to hex
108109
var bin strings.Builder
110+
bin.Grow(len(c.binary))
109111
for _, v := range c.binary {
110112
switch v := v.(type) {
111113
case vm.OpCode:
112-
bin.WriteString(fmt.Sprintf("%x", []byte{byte(v)}))
114+
bin.WriteString(hex.EncodeToString([]byte{byte(v)}))
113115
case []byte:
114-
bin.WriteString(fmt.Sprintf("%x", v))
116+
bin.WriteString(hex.EncodeToString(v))
115117
}
116118
}
117119
return bin.String(), errors

0 commit comments

Comments
 (0)