mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 22:08:55 +00:00
Constructing a serializer value-initialized its three buffers (64 + 512 + 1024 bytes). Each is written before it is read and only the part that was written is ever read, so the zeroing was never needed, but it took about 170 instructions per dump(), more than half of the cost of dumping a small value. Apple M1, Apple clang, per dump(): null 325 -> 153 instructions [1,2,3] 629 -> 458 instructions small object (134 B) 2795 -> 2624 instructions, 190 -> 165 ns (-13 %) a 139-byte object, compact: 2763 -> 2596 instructions (-6 %) Large documents are unchanged. Checked with valgrind memcheck over the differential corpus (no use of uninitialized values), and with GCC 13 -Wall -Wextra -Wmaybe-uninitialized at -O0 to -O3 and -Os. Signed-off-by: Niels Lohmann <mail@nlohmann.me>