Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Improve performance of token compilation #12

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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