code cleanup; fix move ctors and assignment

This commit is contained in:
Günter Obiltschnig
2020-01-21 17:52:43 +01:00
parent de52e23d12
commit 18adb1e43b
20 changed files with 327 additions and 188 deletions

View File

@@ -42,29 +42,15 @@ Object::Object(const Object& other) : _values(other._values),
}
Object::Object(Object&& other):
Object::Object(Object&& other) noexcept:
_values(std::move(other._values)),
_keys(std::move(other._keys)),
_preserveInsOrder(other._preserveInsOrder),
_escapeUnicode(other._escapeUnicode),
_pStruct(!other._modified ? other._pStruct : 0),
_pStruct(std::move(other._pStruct)),
_pOrdStruct(std::move(other._pOrdStruct)),
_modified(other._modified)
{
other.clear();
}
Object &Object::operator = (Object&& other)
{
_values = other._values;
_preserveInsOrder = other._preserveInsOrder;
syncKeys(other._keys);
_escapeUnicode = other._escapeUnicode;
_pStruct = !other._modified ? other._pStruct : 0;
_modified = other._modified;
other.clear();
return *this;
}
@@ -73,7 +59,7 @@ Object::~Object()
}
Object &Object::operator= (const Object &other)
Object &Object::operator = (const Object &other)
{
if (&other != this)
{
@@ -88,6 +74,20 @@ Object &Object::operator= (const Object &other)
}
Object& Object::operator = (Object&& other) noexcept
{
_values = std::move(other._values);
_keys = std::move(other._keys);
_preserveInsOrder = other._preserveInsOrder;
_escapeUnicode = other._escapeUnicode;
_pStruct = std::move(other._pStruct);
_pOrdStruct = std::move(other._pOrdStruct);
_modified = other._modified;
return *this;
}
void Object::syncKeys(const KeyList& keys)
{
if(_preserveInsOrder)