From 7917cfa0f4b62b906a4d54c86905a386f07d7694 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 29 Sep 2026 07:20:09 +0200 Subject: [PATCH] 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 --- include/nlohmann/detail/view/scan.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/nlohmann/detail/view/scan.hpp b/include/nlohmann/detail/view/scan.hpp index fcaf06624..d31f3e9fb 100644 --- a/include/nlohmann/detail/view/scan.hpp +++ b/include/nlohmann/detail/view/scan.hpp @@ -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; }