mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 14:08:13 +00:00
The binary readers read every number and string with get_elements(), which called the virtual std::streambuf::sgetn() each time. When the requested bytes are in the get area, input_stream_adapter now copies them (and moves the get pointer) inline, which is what sgetn() does for them anyway. Instructions relative to the previous commit, from an ifstream (macOS, 5 parses): CBOR CITM 235M -> 226M, twitter 156M -> 151M, canada 495M -> 463M; MessagePack CITM 232M -> 222M; UBJSON CITM 258M -> 241M, canada 638M -> 623M. Linux Ir (GCC / Clang): CBOR twitter 34.0M / 41.9M -> 32.2M / 40.0M, CBOR CITM 51.4M / 58.2M -> 47.7M / 54.6M, MessagePack CITM 50.5M / 57.0M -> 46.8M / 53.4M, UBJSON CITM 56.6M / 64.1M -> 50.7M / 57.9M. Against develop the three binary readers are 5-12 % cheaper in instructions with this series. Signed-off-by: Niels Lohmann <mail@nlohmann.me>