Repository navigation
Conversation
nlohmann
added this pull request to stack #5636
September 29, 2026 14:20
nlohmann
removed this pull request from stack #5636
September 30, 2026 13:19
nlohmann
force-pushed
the
json-view/04-unicode-escapes
branch
from
September 30, 2026 13:20
1372829 to
6c32ac9
Compare
nlohmann
force-pushed
the
json-view/03-string-scan
branch
from
September 30, 2026 13:20
046ad7e to
54c0c07
Compare
nlohmann
added this pull request to stack #5739
September 30, 2026 13:21
nlohmann
force-pushed
the
json-view/03-string-scan
branch
from
September 30, 2026 15:34
54c0c07 to
93b2c99
Compare
nlohmann
force-pushed
the
json-view/04-unicode-escapes
branch
3 times, most recently
from
September 30, 2026 18:06
14c9a28 to
b9fdf44
Compare
nlohmann
marked this pull request as ready for review
September 30, 2026 18:18
get_codepoint() read the four hex digits of a \u escape with four calls to get(), each classified by a chain of range comparisons. For contiguous input, get_codepoint_bulk() now decodes them with one lookup per byte (hex_codepoint() in string_scan.hpp, after yyjson's read_hex_u16): a 256-entry table maps a byte to its value, or 0xFF for anything else, and an invalid digit shows in the OR of the four values. It then skips the four bytes and updates the position counters as four get() calls would. If a digit is invalid or fewer than four bytes are left, it changes nothing and the existing loop runs, so errors are reported with the same message and position as before. json::parse, best of 5 runs in separate processes (M1 Max): the escaped twitter.json (every non-ASCII character as \u) -13.6%, all other files within 0.3%. Tests compare the contiguous and the streaming path (value or exception message) for valid escapes, surrogate pairs, truncated and invalid digits at every position, and 3,000 seeded random escapes. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
force-pushed
the
json-view/04-unicode-escapes
branch
from
September 30, 2026 18:19
b9fdf44 to
d23803f
Compare
…apes Signed-off-by: Niels Lohmann <mail@nlohmann.me>
…apes Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
removed this pull request from stack #5739
October 6, 2026 09:26
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the stack for the zero-copy view (#5295). This change speeds up
json::parseon its own.Summary
get_codepoint()read the four hex digits of a\uXXXXescape with four calls toget(). Each call went through a chain of range comparisons.For contiguous input, the four digits are now decoded with one table lookup per byte (after yyjson's
read_hex_u16). The table maps a byte to its value, or to0xFFfor anything that is not a hex digit, so an invalid digit shows in the OR of the four values. The lexer then skips the four bytes and updates the position counters as fourget()calls would.If a digit is invalid, or fewer than four bytes are left, nothing changes and the existing loop runs. Error messages and positions are therefore exactly as before.
Tests
Benchmarks
json::parsein a separate process, best of 5, Apple M1 Max:\u)This PR originally also compared literals (
true/false/null) withmemcmp. That made citm_catalog, twitter, and mesh.pretty 2–3% slower, so it was dropped.Public API
No change.
Written by Claude Code.
🤖 Generated with Claude Code