mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
Remove harmful vector::reserve during destruction (#1837)
This commit is contained in:
@ -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));
|
||||||
|
@ -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));
|
||||||
|
Reference in New Issue
Block a user