diff options
Diffstat (limited to 'zen/string_base.h')
-rwxr-xr-x | zen/string_base.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/zen/string_base.h b/zen/string_base.h index 3afa66c6..b5e45c0e 100755 --- a/zen/string_base.h +++ b/zen/string_base.h @@ -264,8 +264,8 @@ public: void push_back(Char val) { operator+=(val); } //STL access
void pop_back();
- Zbase& operator=(const Zbase& str);
Zbase& operator=(Zbase&& tmp) noexcept;
+ Zbase& operator=(const Zbase& str);
Zbase& operator=(const Char* str) { return assign(str, strLength(str)); }
Zbase& operator=(Char ch) { return assign(&ch, 1); }
Zbase& operator+=(const Zbase& str) { return append(str.c_str(), str.length()); }
@@ -573,11 +573,14 @@ template <class InputIterator> inline Zbase<Char, SP>& Zbase<Char, SP>::append(InputIterator first, InputIterator last)
{
const size_t len = std::distance(first, last);
- const size_t thisLen = length();
- reserve(thisLen + len); //make unshared and check capacity
-
- *std::copy(first, last, rawStr_ + thisLen) = 0;
- this->setLength(rawStr_, thisLen + len);
+ if (len > 0) //avoid making this string unshared for no reason
+ {
+ const size_t thisLen = length();
+ reserve(thisLen + len); //make unshared and check capacity
+
+ *std::copy(first, last, rawStr_ + thisLen) = 0;
+ this->setLength(rawStr_, thisLen + len);
+ }
return *this;
}
|