We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d33b221 commit 7948954Copy full SHA for 7948954
cores/esp32/WString.cpp
@@ -238,8 +238,12 @@ String &String::copy(const char *cstr, unsigned int length) {
238
#ifdef __GXX_EXPERIMENTAL_CXX0X__
239
void String::move(String &rhs) {
240
if (buffer()) {
241
- if (capacity() >= rhs.len() && rhs.len() && rhs.buffer()) {
242
- memmove(wbuffer(), rhs.buffer(), rhs.length() + 1);
+ if (capacity() >= rhs.len()) {
+ // Use case: When 'reserve()' was called and the first
243
+ // assignment/append is the return value of a function.
244
+ if (rhs.len() && rhs.buffer()) {
245
+ memmove(wbuffer(), rhs.buffer(), rhs.length() + 1);
246
+ }
247
setLen(rhs.len());
248
rhs.invalidate();
249
return;
0 commit comments