wish: reserve method on JSON arrays and objects



    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.


    Basile Starynkevitch - http://starynkevitch.net/Basile/

    Last edit: Basile STARYNKEVITCH 2013-09-28
  • Christopher Dunn

    I want to provide builders for Value. We could then support such a requirement easily.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks