diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 086a1cbed..06ad8041a 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -1322,9 +1322,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() { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index cae779ad5..177a88877 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -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() {