Reserve stack only for top-level items
This commit is contained in:
parent
948f98cf4a
commit
efa13c663d
2 changed files with 4 additions and 0 deletions
|
@ -1004,10 +1004,12 @@ class basic_json
|
|||
// move the top-level items to stack
|
||||
if (t == value_t::array)
|
||||
{
|
||||
stack.reserve(array->size());
|
||||
std::move(array->begin(), array->end(), std::back_inserter(stack));
|
||||
}
|
||||
else if (t == value_t::object)
|
||||
{
|
||||
stack.reserve(object->size());
|
||||
for (auto&& it : *object)
|
||||
{
|
||||
stack.push_back(std::move(it.second));
|
||||
|
|
|
@ -15547,10 +15547,12 @@ class basic_json
|
|||
// move the top-level items to stack
|
||||
if (t == value_t::array)
|
||||
{
|
||||
stack.reserve(array->size());
|
||||
std::move(array->begin(), array->end(), std::back_inserter(stack));
|
||||
}
|
||||
else if (t == value_t::object)
|
||||
{
|
||||
stack.reserve(object->size());
|
||||
for (auto&& it : *object)
|
||||
{
|
||||
stack.push_back(std::move(it.second));
|
||||
|
|
Loading…
Reference in a new issue