Define object_buffer_limit from key_index_threshold

Both mark the size up to which a linear key search is cheap: an object
stays on the stack until then and, once spilled, looks up its keys in
the hash index right away. Defining one from the other keeps them from
drifting apart.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-11-30 08:12:17 +01:00
1 parent 072ee2af83
commit 82ceac7d84
2 files changed
+10 -6

No files matched your search

+5 -3
View File
@@ -17540,9 +17540,11 @@ 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; 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;
/// switches to storing them directly; both collect_member() and a stored
/// object below key_index_threshold search their keys linearly, so the
/// object stays on the stack as long as a linear search is cheap, and a
/// spilled object looks up its keys in a hash table right away
static constexpr std::size_t object_buffer_limit = key_index_threshold;
void reserve_members()
{