Commit b5105fc5 authored by Igor Sugak's avatar Igor Sugak Committed by Facebook Github Bot

fix -Wreturn-std-move errors

Summary:
This was exposed by the latest clang with -Wreturn-std-move enabled:
```lang=bash
folly/FBString.h:2487:12: error: local variable 'rhs' will be copied despite being returned by name [-Werror,-Wreturn-std-move]
    return rhs;
           ^~~
folly/test/FBStringTest.cpp:1294:23: note: in instantiation of function template specialization 'folly::operator+<char, std::char_traits<char>, std::allocator<char>, folly::fbstring_core<char> >' requested here
    auto test1 = '\0' + std::move(s1);
                      ^
folly/FBString.h:2487:12: note: call 'std::move' explicitly to avoid copying
    return rhs;
           ^~~
           std::move(rhs)
2 errors generated.
```

Reviewed By: Orvid

Differential Revision: D7776805

fbshipit-source-id: f11ae5a1fc416b8838b8ea74d7f6b488f07cab38
parent 4e12f97c
......@@ -2451,7 +2451,7 @@ basic_fbstring<E, T, A, S> operator+(
if (rhs.capacity() >= len + rhs.size()) {
// Good, at least we don't need to reallocate
rhs.insert(rhs.begin(), lhs, lhs + len);
return rhs;
return std::move(rhs);
}
// Meh, no go. Do it by hand since we have len already.
basic_fbstring<E, T, A, S> result;
......@@ -2484,7 +2484,7 @@ basic_fbstring<E, T, A, S> operator+(
if (rhs.capacity() > rhs.size()) {
// Good, at least we don't need to reallocate
rhs.insert(rhs.begin(), lhs);
return rhs;
return std::move(rhs);
}
// Meh, no go. Forward to operator+(E, const&).
auto const& rhsC = rhs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment