mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 14:08:13 +00:00
An array that unflatten() creates grows by one element at a time, so an array of two elements (a coordinate pair, a range) was allocated, grown and freed once more than needed. New arrays get room for two elements first, for array types that have reserve(). Arrays of two or more elements need no more memory than before; an array of one element has room for one more. unflatten() (instructions on macOS, Linux Ir GCC 13 / Clang 18): canada 161.9M -> 141.2M, 128.3M -> 117.9M / 138.0M -> 128.6M; citm_catalog 43.5M -> 42.8M, 37.0M -> 36.8M / 37.5M -> 37.3M; twitter unchanged. Signed-off-by: Niels Lohmann <mail@nlohmann.me>