Commit efa13c66 authored by Isaac Nickaein's avatar Isaac Nickaein

Reserve stack only for top-level items

parent 948f98cf
...@@ -1004,10 +1004,12 @@ class basic_json ...@@ -1004,10 +1004,12 @@ class basic_json
// move the top-level items to stack // move the top-level items to stack
if (t == value_t::array) if (t == value_t::array)
{ {
stack.reserve(array->size());
std::move(array->begin(), array->end(), std::back_inserter(stack)); std::move(array->begin(), array->end(), std::back_inserter(stack));
} }
else if (t == value_t::object) else if (t == value_t::object)
{ {
stack.reserve(object->size());
for (auto&& it : *object) for (auto&& it : *object)
{ {
stack.push_back(std::move(it.second)); stack.push_back(std::move(it.second));
......
...@@ -15547,10 +15547,12 @@ class basic_json ...@@ -15547,10 +15547,12 @@ class basic_json
// move the top-level items to stack // move the top-level items to stack
if (t == value_t::array) if (t == value_t::array)
{ {
stack.reserve(array->size());
std::move(array->begin(), array->end(), std::back_inserter(stack)); std::move(array->begin(), array->end(), std::back_inserter(stack));
} }
else if (t == value_t::object) else if (t == value_t::object)
{ {
stack.reserve(object->size());
for (auto&& it : *object) for (auto&& it : *object)
{ {
stack.push_back(std::move(it.second)); stack.push_back(std::move(it.second));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment