diff --git a/doomsday/libs/core/include/de/data/block.h b/doomsday/libs/core/include/de/data/block.h index 7d69f2f275..d90ab62413 100644 --- a/doomsday/libs/core/include/de/data/block.h +++ b/doomsday/libs/core/include/de/data/block.h @@ -127,6 +127,7 @@ class DE_PUBLIC Block Block &operator+=(const IByteArray &byteArray); Block &operator=(const Block &other); + Block &operator=(Block &&moved); Block &operator=(const IByteArray &byteArray); Block compressed(int level = -1) const; diff --git a/doomsday/libs/core/include/de/data/string.h b/doomsday/libs/core/include/de/data/string.h index edf892f7d8..3fea0fde03 100644 --- a/doomsday/libs/core/include/de/data/string.h +++ b/doomsday/libs/core/include/de/data/string.h @@ -262,12 +262,7 @@ class DE_PUBLIC String : public IByteArray inline String &operator=(String &&moved) { - if (_str.chars.i) - { - deinit_String(&_str); - } - _str = moved._str; - zap(moved._str); + set_String(&_str, &moved._str); return *this; } diff --git a/doomsday/libs/core/src/data/block.cpp b/doomsday/libs/core/src/data/block.cpp index 91ed19c9ed..1b75fcefff 100644 --- a/doomsday/libs/core/src/data/block.cpp +++ b/doomsday/libs/core/src/data/block.cpp @@ -51,8 +51,7 @@ Block::Block(const Block &other) Block::Block(Block &&moved) { - _block = moved._block; - iZap(moved._block); + set_Block(&_block, &moved._block); } Block::Block(const char *nullTerminatedCStr) @@ -274,10 +273,16 @@ Block &Block::operator+=(const IByteArray &byteArray) Block &Block::operator=(const Block &other) { - set_Block(&_block, other); + set_Block(&_block, &other._block); return *this; } +Block &Block::operator=(Block &&moved) +{ + set_Block(&_block, &moved._block); + return *this; +} + Block &Block::operator=(const IByteArray &byteArray) { copyFrom(byteArray, 0, byteArray.size()); diff --git a/doomsday/libs/core/src/data/string.cpp b/doomsday/libs/core/src/data/string.cpp index 3da4f91bda..1baae65d96 100644 --- a/doomsday/libs/core/src/data/string.cpp +++ b/doomsday/libs/core/src/data/string.cpp @@ -1,7 +1,7 @@ /* * The Doomsday Engine Project -- libcore * - * Copyright © 2004-2017 Jaakko Keränen + * Copyright © 2004-2018 Jaakko Keränen * * @par License * LGPL: http://www.gnu.org/licenses/lgpl.html @@ -46,8 +46,7 @@ String::String(const String &other) String::String(String &&moved) { - _str = moved._str; - iZap(moved._str); + initCopy_String(&_str, &moved._str); } String::String(const Block &bytes)