<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 17, 2013 at 12:23 PM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@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 dir="rtl"><div dir="ltr">Yes, using .str() will work, but it involves creating yet another temporary, a StringRef</div>
</div></blockquote><div><br></div><div>Constructing a StringRef is cheap.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">
returned from .str() and then converted to std::string. </div></div></blockquote><div><br></div><div>Conversion/return from std::string should invoke RVO, at least. That just leaves the copy in the assignment which in C++11 would be move assignment. We only really care about performance of LLVM and Clang in a C++11 build anyway, so I'm OK with relying on that for performance (though move assignment isn't quite as efficient as the assign call, since it can't reuse the string's existing buffer - but since the string was just default constructed it won't have any existing buffer (on any well-performing implementation) to begin with).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">An optimizer may help here.</div><div dir="ltr">
The most efficient code would be </div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><font face="courier new, monospace"> MainFileName.assign(MainFileDirSS.data(), MainFileDirSS.size());</font></div><div><br>
</div><div>What I was hoping for is to avoid using the SmallString conversions. </div><div><br></div><div>Are the path functions using SmallStrings for efficiency or is there another reason?</div></div></div></blockquote>
<div><br></div><div>Since they need to mutate the argument they have to choose some concrete string type and SmallString is generally preferred in the LLVM codebase. It might be easier to just change MainFileName to SmallString if that's practical (unless some other caller needs it in a std::string)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr"><span class="HOEnZb"><font color="#888888"><div><br></div><div>Yaron<br>
</div></font></span></div><div><div class="h5"><div class="gmail_extra"><div dir="ltr"><br><br><div class="gmail_quote">2013/10/17 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 .8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1ex;padding-right:1ex">
I think instead of writing:<br><br>MainFileName = std::string(MainFileDirSS.data(), MainFileDirSS.size());<br><br>you can just write:<br><br>MainFileName = MainFileDirSS.str();<br><br>Hopefully.</blockquote></div><div class="gmail_extra">
<br><br><div class="gmail_quote"><div>On Thu, Oct 17, 2013 at 8:09 AM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>></span> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div dir="rtl"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">Filename appending in CGDebugInfo.cpp was implemented as simple string concatenation, resulting in duplicate file debug information on Windows due to wrong path separator.</div>
<div dir="ltr"><br></div><div dir="ltr">The patch uses llvm::sys::path::append to properly append the filename on all OS.</div><div dir="ltr"><br></div><div dir="ltr">Is there a way to use path::append without the SmallString temporary?</div>
<span><font color="#888888">
<div dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div></font></span></div>
<br></div></div>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div></div></div></div></div>
</blockquote></div><br></div></div>