Read whole blocks of eight digits of json_view directly

A block of eight digits of a number token lies inside the input (the
digits were counted while scanning, or are recorded in the digit
layout), so parse_upto19() reads it without the bounds check of the
last, partial block. Traversing canada.json: -11% instructions, -6%
cycles.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 07:20:09 +02:00
parent b5da87a5e3
commit 7917cfa0f4
+2 -1
View File
@@ -175,7 +175,8 @@ NLOHMANN_VIEW_ALWAYS_INLINE std::uint64_t parse_upto19(const unsigned char* p, u
std::uint64_t w = 0;
while (k >= 8)
{
w = (w * 100000000u) + parse_upto8(p, 8, limit);
// (eight digits of the token: they lie below limit)
w = (w * 100000000u) + parse_eight_digits(read_eight_bytes(p));
p += 8;
k -= 8;
}