From d4486107702876c12778fbc11f5c7d33b4bd6094 Mon Sep 17 00:00:00 2001 From: Jordan Bayles Date: Wed, 25 Sep 2019 14:05:45 -0700 Subject: [PATCH] Fixup Json::Value append methods, run clang format. (#1022) --- src/lib_json/json_value.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index cce2b29..e2cb7a1 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -1155,10 +1155,14 @@ Value const& Value::operator[](CppTL::ConstString const& key) const { } #endif -Value& Value::append(const Value& value) { return (*this)[size()] = value; } - +Value& Value::append(const Value& value) { return append(Value(value)); } Value& Value::append(Value&& value) { - return (*this)[size()] = std::move(value); + JSON_ASSERT_MESSAGE(type() == nullValue || type() == arrayValue, + "in Json::Value::append: requires arrayValue"); + if (type() == nullValue) { + *this = Value(arrayValue); + } + return this->value_.map_->emplace(size(), std::move(value)).first->second; } Value Value::get(char const* begin,