mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 22:08:55 +00:00
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>