<div dir="rtl"><div dir="ltr">Could we assume that getMainExecutable result is a fixed constant while the program runs, cache the result in a static std::string and return a StringRef to the statc string?</div><div dir="ltr"><br></div><div dir="ltr"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div dir="ltr">2014-12-29 23:37 GMT+02:00 Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span>:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Dec 29, 2014 at 1:07 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br></span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span><br><div class="gmail_quote">On Mon, Dec 29, 2014 at 12:59 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">Author: samsonov<br>
Date: Mon Dec 29 14:59:02 2014<br>
New Revision: 224953<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224953&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=224953&view=rev</a><br>
Log:<br>
Remove unnecessary StringRef->std::string conversion.<br>
<br>
Modified:<br>
llvm/trunk/lib/Support/Unix/Path.inc<br>
<br>
Modified: llvm/trunk/lib/Support/Unix/Path.inc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=224953&r1=224952&r2=224953&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=224953&r1=224952&r2=224953&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/Unix/Path.inc (original)<br>
+++ llvm/trunk/lib/Support/Unix/Path.inc Mon Dec 29 14:59:02 2014<br>
@@ -150,7 +150,7 @@ std::string getMainExecutable(const char<br>
// /proc is not always mounted under Linux (chroot for example).<br>
ssize_t len = readlink(aPath.str().c_str(), exe_path, sizeof(exe_path));<br>
if (len >= 0)<br>
- return StringRef(exe_path, len);<br>
+ return std::string(exe_path, len);</div></blockquote></div></span></div></div></blockquote><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span></span>Are you sure RVO can fire here? If not, this adds a std::string copy....</div></div></blockquote><div><br></div></div></div><div>Implementation of StringRef -> std::string() conversion overaptor calls the same std::string(Data, Length) constructor.</div></div><span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</font></span></div></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>