[llvm] r224953 - Remove unnecessary StringRef->std::string conversion.
David Blaikie
dblaikie at gmail.com
Mon Dec 29 13:12:11 PST 2014
On Mon, Dec 29, 2014 at 1:07 PM, Chandler Carruth <chandlerc at google.com>
wrote:
>
>
> On Mon, Dec 29, 2014 at 12:59 PM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
>
>> Author: samsonov
>> Date: Mon Dec 29 14:59:02 2014
>> New Revision: 224953
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=224953&view=rev
>> Log:
>> Remove unnecessary StringRef->std::string conversion.
>>
>> Modified:
>> llvm/trunk/lib/Support/Unix/Path.inc
>>
>> Modified: llvm/trunk/lib/Support/Unix/Path.inc
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=224953&r1=224952&r2=224953&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Unix/Path.inc (original)
>> +++ llvm/trunk/lib/Support/Unix/Path.inc Mon Dec 29 14:59:02 2014
>> @@ -150,7 +150,7 @@ std::string getMainExecutable(const char
>> // /proc is not always mounted under Linux (chroot for example).
>> ssize_t len = readlink(aPath.str().c_str(), exe_path,
>> sizeof(exe_path));
>> if (len >= 0)
>> - return StringRef(exe_path, len);
>> + return std::string(exe_path, len);
>>
>
> Are you sure RVO can fire here? If not, this adds a std::string copy....
>
At best it should add an extra move (guaranteed), but I believe RVO would
fire - my naive understanding is that if at the time the return value is
constructed, it's guaranteed to be the return value (all paths from the
construction return that object) then (N)RVO can fire. I'm not sure of what
cases where non-named RVO would not fire, really... so perhaps I'm missing
something.
- David
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141229/eeec7273/attachment.html>
More information about the llvm-commits
mailing list