Files
json/include/nlohmann/detail
Niels Lohmann 62b238dce8 Validate runs of non-ASCII bytes with a shift-based UTF-8 DFA
The scalar bulk paths validated non-ASCII text one sequence at a time with
validate_one_utf8(). Replace these loops with a shift-based DFA (one table
load and one shift per byte, no branch on the byte):

- utf8_dfa_run() in scalar_string_bulk_run(): the lexer and the serializer
  without SSE2/NEON, and on x86 CPUs without SSSE3. On an error, the exact
  position comes from utf8_dfa_prefix(), so diagnostics are unchanged.
- utf8_dfa_prefix() in valid_utf8_prefix(): the BON8 reader (all builds),
  the BON8 writer and the BSON name check.

Both stop at the first ill-formed byte, so the serializer's error handlers
stay linear. On Apple M, CJK text (poet.json) got 30% faster in the lexer and
serializer without SIMD, and BON8 reading got 15% faster with SIMD.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-11-30 18:11:18 +01:00
..