1
0
mirror of https://github.com/nlohmann/json synced 2024-11-12 23:40:05 +00:00

more cleanup

This commit is contained in:
Niels 2015-05-10 17:03:50 +02:00
parent 76d3433e6c
commit 43ededf41f
2 changed files with 8 additions and 24 deletions

View File

@ -506,9 +506,7 @@ class basic_json
{ {
// the initializer list is a list of pairs -> create object // the initializer list is a list of pairs -> create object
m_type = value_t::object; m_type = value_t::object;
AllocatorType<object_t> alloc; m_value = value_t::object;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
for (auto& element : init) for (auto& element : init)
{ {
@ -1721,9 +1719,7 @@ class basic_json
if (m_type == value_t::null) if (m_type == value_t::null)
{ {
m_type = value_t::array; m_type = value_t::array;
AllocatorType<array_t> alloc; m_value = value_t::array;
m_value.array = alloc.allocate(1);
alloc.construct(m_value.array);
} }
// add element to array (move semantics) // add element to array (move semantics)
@ -1752,9 +1748,7 @@ class basic_json
if (m_type == value_t::null) if (m_type == value_t::null)
{ {
m_type = value_t::array; m_type = value_t::array;
AllocatorType<array_t> alloc; m_value = value_t::array;
m_value.array = alloc.allocate(1);
alloc.construct(m_value.array);
} }
// add element to array // add element to array
@ -1781,9 +1775,7 @@ class basic_json
if (m_type == value_t::null) if (m_type == value_t::null)
{ {
m_type = value_t::object; m_type = value_t::object;
AllocatorType<object_t> alloc; m_value = value_t::object;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
} }
// add element to array // add element to array

View File

@ -506,9 +506,7 @@ class basic_json
{ {
// the initializer list is a list of pairs -> create object // the initializer list is a list of pairs -> create object
m_type = value_t::object; m_type = value_t::object;
AllocatorType<object_t> alloc; m_value = value_t::object;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
for (auto& element : init) for (auto& element : init)
{ {
@ -1721,9 +1719,7 @@ class basic_json
if (m_type == value_t::null) if (m_type == value_t::null)
{ {
m_type = value_t::array; m_type = value_t::array;
AllocatorType<array_t> alloc; m_value = value_t::array;
m_value.array = alloc.allocate(1);
alloc.construct(m_value.array);
} }
// add element to array (move semantics) // add element to array (move semantics)
@ -1752,9 +1748,7 @@ class basic_json
if (m_type == value_t::null) if (m_type == value_t::null)
{ {
m_type = value_t::array; m_type = value_t::array;
AllocatorType<array_t> alloc; m_value = value_t::array;
m_value.array = alloc.allocate(1);
alloc.construct(m_value.array);
} }
// add element to array // add element to array
@ -1781,9 +1775,7 @@ class basic_json
if (m_type == value_t::null) if (m_type == value_t::null)
{ {
m_type = value_t::object; m_type = value_t::object;
AllocatorType<object_t> alloc; m_value = value_t::object;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
} }
// add element to array // add element to array