Repository navigation
Conversation
nlohmann
added this pull request to stack #5636
September 29, 2026 14:20
Owner
Author
|
CI fixes for this PR (commit 046ad7e, plus the fixes from #5617 merged in):
Verified with GCC 16 using the CI flags (the test passes). #5619 (json-view/04-unicode-escapes) got only a propagation merge; its failures were all inherited from here and from #5617. — posted by Claude Code on behalf of @nlohmann |
This was referenced Sep 29, 2026
nlohmann
removed this pull request from stack #5636
September 30, 2026 13:19
nlohmann
force-pushed
the
json-view/03-string-scan
branch
from
September 30, 2026 13:20
046ad7e to
54c0c07
Compare
nlohmann
changed the base branch from
json-view/02-eisel-lemire
to
json-view/02b-float-parser
September 30, 2026 13:21
nlohmann
added this pull request to stack #5739
September 30, 2026 13:21
nlohmann
force-pushed
the
json-view/03-string-scan
branch
3 times, most recently
from
September 30, 2026 18:06
bcbee74 to
1df6f5e
Compare
nlohmann
marked this pull request as ready for review
September 30, 2026 18:18
find_string_special() and find_ascii_copyable_run() test eight bytes at a time, but located the stopping byte inside a word with a byte loop. The lowest flagged byte of the SWAR tests is always a true hit (the borrows of the subtractions can only flag bytes above one), so its index is now the trailing-zero count of the mask; words are read in little-endian order on every platform, so this does not depend on the byte order. scalar_string_bulk_run() validates a run of multi-byte UTF-8 sequences one after another instead of searching for the next special byte in between, which helps text in non-Latin scripts. The kernels serve the lexer's contiguous fast path, the serializer, and the binary formats. New tests compare all three with byte-by-byte reference scans on 100,000 generated buffers at three alignments; the portable fallback of count_trailing_zeros() was checked against the builtin. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
GCC -Werror=useless-cast rejected static_cast<std::size_t>(next() % n): on 64-bit Linux std::uint64_t and std::size_t are the same type, while the cast is needed where std::size_t is 32 bits wide. Draw the sizes from a 32-bit value instead, which converts to std::size_t implicitly on every platform. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
force-pushed
the
json-view/03-string-scan
branch
from
September 30, 2026 18:19
1df6f5e to
f1014c9
Compare
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
… HEAD 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::parseanddump()on its own; the view uses the same kernels later.Summary
The string kernels in
detail/input/string_scan.hpptest eight bytes at a time. Until now, once a word contained a byte to stop at, the kernels found that byte with a byte loop. The lowest flagged byte of the SWAR tests is always a real hit, because the borrows of the subtractions can only flag bytes above one. So its index is now the trailing-zero count of the mask.Words are assembled in little-endian order on every platform, so the result doesn't depend on the byte order.
count_trailing_zeros()has a portable fallback.Non-ASCII text:
scalar_string_bulk_run()now validates a run of multi-byte UTF-8 sequences one after another, instead of searching for the next special byte after each sequence. This helps text in non-Latin scripts.The kernels serve the lexer's contiguous fast path, the serializer, and the binary formats.
Tests
count_trailing_zeros()is checked against the builtin.Benchmarks
tests/benchmarks: Apple M1 Max, Apple clang 21,-O3 -flto, median of 2×5 interleaved repetitions:ParseFile reads from a stream and does not use these kernels; its rows are unchanged (within noise).
json::parsein a separate process, best of 5:Public API
No change.
Written by Claude Code.
🤖 Generated with Claude Code