Commit 0f3ec003 authored by Isaac Nickaein's avatar Isaac Nickaein

Remove harmful vector::reserve during destruction (#1837)

parent be61ad14
......@@ -1004,13 +1004,10 @@ 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));
......@@ -1027,8 +1024,6 @@ class basic_json
// its children to the stack to be processed later
if (current_item.is_array())
{
stack.reserve(stack.size() + current_item.m_value.array->size());
std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(),
std::back_inserter(stack));
......@@ -1036,8 +1031,6 @@ class basic_json
}
else if (current_item.is_object())
{
stack.reserve(stack.size() + current_item.m_value.object->size());
for (auto&& it : *current_item.m_value.object)
{
stack.push_back(std::move(it.second));
......
......@@ -15547,13 +15547,10 @@ 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));
......@@ -15570,8 +15567,6 @@ class basic_json
// its children to the stack to be processed later
if (current_item.is_array())
{
stack.reserve(stack.size() + current_item.m_value.array->size());
std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(),
std::back_inserter(stack));
......@@ -15579,8 +15574,6 @@ class basic_json
}
else if (current_item.is_object())
{
stack.reserve(stack.size() + current_item.m_value.object->size());
for (auto&& it : *current_item.m_value.object)
{
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