use sync.Pool for temporal bytes.Buffer.
remove ev.Value and ev.Values
before:
scanblock: 8.22s (14.83%)
runtime.MScan_Sweep 4.99s(9.00%)
after:
scanblock: 7.42s (12.95%)
runtime.MScan_Sweep 4.57s(7.98%)
diff --git a/ast.go b/ast.go
index 602a329..2c7fc3a 100644
--- a/ast.go
+++ b/ast.go
@@ -1,6 +1,7 @@
package main
import (
+ "bytes"
"fmt"
"strings"
)
@@ -45,7 +46,9 @@
if err != nil {
panic(fmt.Errorf("parse assign rhs %s:%d %v", ast.filename, ast.lineno, err))
}
- return SimpleVar{value: ev.Value(rexpr), origin: origin}
+ var buf bytes.Buffer
+ rexpr.Eval(&buf, ev)
+ return SimpleVar{value: buf.Bytes(), origin: origin}
case "=":
v, _, err := parseExpr([]byte(ast.rhs), nil)
if err != nil {