Files
json/include
Niels Lohmann 419133b2af Step over a character in the get area without leaving get_character()
input_stream_adapter::get_character() was an out-of-line function that
checked for a refill, called sbumpc(), checked for EOF and updated the token
bookkeeping for every character. Characters that come from the get area -
nearly all of them - now take a short inline path (pointer compare, one
store, gbump(1)); the refill, EOF and no-get-area cases moved to an
out-of-line get_character_slow(). Default mode only; with
JSON_PRECISE_STREAM_POSITION the adapter is unchanged.

Instructions, istream/istringstream/custom streambuf, relative to develop
(macOS, 5 parses): CITM from an ifstream 399M -> 380M (-5 %), from an
istringstream 383M -> 366M, twitter 186M -> 179M, canada 979M -> 953M,
accept() twitter 109M -> 102M, accept() CITM 250M -> 231M. Linux Ir (GCC / Clang): CITM 89.0M / 122.1M ->
84.6M / 118.7M, twitter 42.5M / 54.3M -> 40.8M / 52.9M, canada 198.3M /
243.3M -> 192.0M / 237.4M, accept() twitter 25.4M / 36.9M -> 23.7M / 35.5M,
NDJSON 95.5M / 118.7M -> 91.2M / 115.2M. FILE* input is unchanged.

Streambufs without a get area get 3-5 % slower with this commit alone (CITM
1205M -> 1246M on macOS, 207.5M -> 218.9M Ir with GCC); a later commit in
this series makes that path shorter than before.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-22 09:28:33 +02:00
..