perf(parser): scan the input as bytes instead of runes

Assisted-by: GLM 5.3
This commit is contained in:
2026-09-17 23:11:50 +02:00
parent 3c8ac859c0
commit f1a757ec5c
3 changed files with 128 additions and 91 deletions
+5
View File
@@ -42,6 +42,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
and shared with the encoder, which now resolves duplicate field keys with
it. Strict decoding of an array of tables of structs runs about a quarter
faster; marshalling structs gained the same layout without measurable cost.
- The parser scans the input bytes in place instead of building a `[]rune`
copy of the document: every character that drives the grammar is ASCII and
the input is validated UTF-8 up front, so the conversion pass and its four
bytes per rune were pure overhead. Parsing a large array-of-tables document
runs about a fifth faster and allocates about half the memory.
### Fixed