Three techniques for building high performance parsers
summary
Shows an implementation that replaces encoding/json.Decoder with a streaming, allocation-conscious parser using a windowed byte reader that returns subslices, a tokenizer inlining hot paths to avoid per-byte function calls, and a state machine that stores state-as-function handlers to eliminate branch mispredictions. Claims: tokenized decoding is ~2–3× faster than encoding/json for Decoder-style API, up to 10× faster using the subslice NextToken API, and 1–1.5× for full Unmarshal; code is live and reduces allocations substantially.
AI-written summary · about
