Collect up to 64 members of an ordered_json object on the stack
The DOM parser collects the members of an ordered_json object on a stack and moves them into a vector of the exact size at the closing brace. Objects with more than 32 members were spilled into a growing vector, which then took the linear-search operator[] until the key index starts at 64 members. Collecting up to 64 members closes that gap: an object either fits on the stack or is spilled straight into the indexed path. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
3 files changed
+8
-6
No files matched your search
@@ -1322,8 +1322,9 @@ class json_sax_dom_parser : public json_sax_dom_error_state
|
||||
}
|
||||
|
||||
/// the number of members an object collects on the stack before it
|
||||
/// switches to storing them directly
|
||||
static constexpr std::size_t object_buffer_limit = 32;
|
||||
/// switches to storing them directly; this is the size from which the
|
||||
/// stored object looks up its keys in a hash table (key_index_threshold)
|
||||
static constexpr std::size_t object_buffer_limit = 64;
|
||||
|
||||
void reserve_members()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user