Files
json/include/nlohmann/detail/output
Niels Lohmann 985fa5cb2e Keep a cursor and an end pointer in the vector sink
The vector sink kept the vector and a position, so that every write or
reservation read the vector's begin and end, subtracted them and the position,
and added the position to the data pointer again for the store.

It now keeps the write pointer and the end of the vector. A capacity check is
a subtraction of two members, and the pointer is the one to store to. Both are
set again whenever the vector grows; the destructor still trims the vector to
what was written, also when a write throws.

Instructions per call (Linux, GCC 13, thousands), to_bon8: 20000 small objects 23279 -> 20741, citm_catalog 7974 -> 7335; to_msgpack: 20000 small objects 13641 -> 12702; to_ubjson: 20000 small objects 14620 -> 13620; to_bjdata: 20000 small objects 14641 -> 13641.

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