mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-11 15:55:23 +08:00
libcpp: Avoid pessimizing std::move [PR106272]
std::move in a return statement can prevent the NRVO: <https://developers.redhat.com/blog/2019/04/12/understanding-when-not-to-stdmove-in-c> PR106272 reports that we have two such cases in class label_text's member functions. We have -Wpessimizing-move that's supposed to detect problematic std::move uses, but in this case it didn't trigger. I've filed PR106276 to track that. PR preprocessor/106272 libcpp/ChangeLog: * include/line-map.h (class label_text): Don't std::move in a return statement.
This commit is contained in:
parent
f70c185242
commit
86a15b266a
@ -1873,13 +1873,13 @@ public:
|
||||
longer-lived owner. */
|
||||
static label_text borrow (const char *buffer)
|
||||
{
|
||||
return std::move (label_text (const_cast <char *> (buffer), false));
|
||||
return label_text (const_cast <char *> (buffer), false);
|
||||
}
|
||||
|
||||
/* Create a label_text instance that takes ownership of BUFFER. */
|
||||
static label_text take (char *buffer)
|
||||
{
|
||||
return std::move (label_text (buffer, true));
|
||||
return label_text (buffer, true);
|
||||
}
|
||||
|
||||
/* Take ownership of the buffer, copying if necessary. */
|
||||
|
Loading…
Reference in New Issue
Block a user