From 43ededf41fa89864f2c90b1202c12b3d998275d2 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 10 May 2015 17:03:50 +0200 Subject: [PATCH] more cleanup --- src/json.hpp | 16 ++++------------ src/json.hpp.re2c | 16 ++++------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index aea5ba69..cc6f94cf 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -506,9 +506,7 @@ class basic_json { // the initializer list is a list of pairs -> create object m_type = value_t::object; - AllocatorType alloc; - m_value.object = alloc.allocate(1); - alloc.construct(m_value.object); + m_value = value_t::object; for (auto& element : init) { @@ -1721,9 +1719,7 @@ class basic_json if (m_type == value_t::null) { m_type = value_t::array; - AllocatorType alloc; - m_value.array = alloc.allocate(1); - alloc.construct(m_value.array); + m_value = value_t::array; } // add element to array (move semantics) @@ -1752,9 +1748,7 @@ class basic_json if (m_type == value_t::null) { m_type = value_t::array; - AllocatorType alloc; - m_value.array = alloc.allocate(1); - alloc.construct(m_value.array); + m_value = value_t::array; } // add element to array @@ -1781,9 +1775,7 @@ class basic_json if (m_type == value_t::null) { m_type = value_t::object; - AllocatorType alloc; - m_value.object = alloc.allocate(1); - alloc.construct(m_value.object); + m_value = value_t::object; } // add element to array diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 98368f17..ec484860 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -506,9 +506,7 @@ class basic_json { // the initializer list is a list of pairs -> create object m_type = value_t::object; - AllocatorType alloc; - m_value.object = alloc.allocate(1); - alloc.construct(m_value.object); + m_value = value_t::object; for (auto& element : init) { @@ -1721,9 +1719,7 @@ class basic_json if (m_type == value_t::null) { m_type = value_t::array; - AllocatorType alloc; - m_value.array = alloc.allocate(1); - alloc.construct(m_value.array); + m_value = value_t::array; } // add element to array (move semantics) @@ -1752,9 +1748,7 @@ class basic_json if (m_type == value_t::null) { m_type = value_t::array; - AllocatorType alloc; - m_value.array = alloc.allocate(1); - alloc.construct(m_value.array); + m_value = value_t::array; } // add element to array @@ -1781,9 +1775,7 @@ class basic_json if (m_type == value_t::null) { m_type = value_t::object; - AllocatorType alloc; - m_value.object = alloc.allocate(1); - alloc.construct(m_value.object); + m_value = value_t::object; } // add element to array