mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 14:08:13 +00:00
flatten() appended the entries to an ordered_map one by one, so its vector grew by doubling and moved every entry about once in total. The number of entries is known after a walk over the value that only counts (it needs no path strings), so objects with a reserve() are given that capacity first. std::map has no reserve() and is unchanged. flatten() of an ordered_json (instructions on macOS, Linux Ir GCC 13 / Clang 18): citm_catalog 36.8M -> 23.1M, 32.7M -> 17.1M / 31.7M -> 16.8M; twitter 20.5M -> 13.6M, 17.6M -> 10.0M / 17.0M -> 9.8M. Output is identical. Signed-off-by: Niels Lohmann <mail@nlohmann.me>