Background
decode_string currently scans for backslash escape sequences byte-by-byte in its inner loop. The structural scanner already uses SIMD to skip over long string interiors at the Phase 1 level, but Phase 2 decode_string pays the linear byte scan cost every time an escaped string is accessed.
Proposal
Add a SIMD probe inside decode_string (src/decode/string.rs) that searches for \ using AVX2 / NEON intrinsics (or falls back to memchr on scalar builds), jumping past unescaped runs in bulk rather than one byte at a time.
This mirrors the in-string fast path already present in the structural scanners (src/scan/avx2.rs, src/scan/neon.rs).
Expected impact
Meaningful win on payloads with many long escaped strings (e.g. embedded JSON, long base64 with \/ escapes). No effect on strings without backslashes (those already take the borrow-slice fast path and never enter the escape loop).
Notes
- Gate behind the same feature flags (
avx2, neon) used by the structural scanners, or use memchr as a portable alternative that the compiler may auto-vectorize.
- Add a bench fixture or micro-benchmark with a string-escape-heavy payload to measure before/after.
Background
decode_stringcurrently scans for backslash escape sequences byte-by-byte in its inner loop. The structural scanner already uses SIMD to skip over long string interiors at the Phase 1 level, but Phase 2decode_stringpays the linear byte scan cost every time an escaped string is accessed.Proposal
Add a SIMD probe inside
decode_string(src/decode/string.rs) that searches for\using AVX2 / NEON intrinsics (or falls back tomemchron scalar builds), jumping past unescaped runs in bulk rather than one byte at a time.This mirrors the in-string fast path already present in the structural scanners (
src/scan/avx2.rs,src/scan/neon.rs).Expected impact
Meaningful win on payloads with many long escaped strings (e.g. embedded JSON, long base64 with
\/escapes). No effect on strings without backslashes (those already take the borrow-slice fast path and never enter the escape loop).Notes
avx2,neon) used by the structural scanners, or usememchras a portable alternative that the compiler may auto-vectorize.