Skip to content

Commit

Permalink
Improve performance of token compilation (ethereum#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen authored and avalonche committed Mar 9, 2023
1 parent 9292b34 commit 1b39032
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/asm/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package asm

import (
"encoding/hex"
"fmt"
"math/big"
"os"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1b39032

Please sign in to comment.