It would be nice if Json::Value had a member function void reserve(size_t sz); to reserve space (without filling it), in the same way as the standard C++ template std::vector. So if a Json::Value jv is an object jv.reserve(5) would pre-allocate (without resizing it!) memory for at least 5 attribute-value entries, and if jv is an array jv.reserve(12) would pre-allocate memory for 12 array components.
This could change the complexity of programs filling progressively a Json::Value (e.g. a loop doing an append)
Ii am not familiar enough with the implementation to quickly propose a patch.
Hello,
It would be nice if Json::Value had a member function void reserve(size_t sz); to reserve space (without filling it), in the same way as the standard C++ template std::vector. So if a Json::Value jv is an object jv.reserve(5) would pre-allocate (without resizing it!) memory for at least 5 attribute-value entries, and if jv is an array jv.reserve(12) would pre-allocate memory for 12 array components.
This could change the complexity of programs filling progressively a Json::Value (e.g. a loop doing an append)
Ii am not familiar enough with the implementation to quickly propose a patch.
Regards.
--
Basile Starynkevitch - http://starynkevitch.net/Basile/
Last edit: Basile STARYNKEVITCH 2013-09-28
I want to provide builders for
Value
. We could then support such a requirement easily.