perf(parser): scan the input as bytes instead of runes
Assisted-by: GLM 5.3
This commit is contained in:
+3
-1
@@ -110,7 +110,9 @@ func ParseContext(ctx context.Context, data []byte) (map[string]any, error) {
|
||||
if !utf8.Valid(data) {
|
||||
return nil, &SyntaxError{Line: 1, Msg: "input is not valid UTF-8"}
|
||||
}
|
||||
p := &parser{src: []rune(string(data)), line: 1, ctx: ctx}
|
||||
// The parser scans data in place; it only reads the buffer, and every
|
||||
// string it stores in the tree is copied out of it.
|
||||
p := &parser{src: data, line: 1, ctx: ctx}
|
||||
return p.parse()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user