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

This commit is contained in:
Isaac Nickaein 2019-11-12 22:19:55 +03:30
parent be61ad1470
commit 0f3ec003bb
2 changed files with 0 additions and 14 deletions

View file

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

View file

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