<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 27, 2018 at 7:51 AM Eric Liu via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ioeric<br>
Date: Thu Sep 27 07:50:24 2018<br>
New Revision: 343224<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=343224&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=343224&view=rev</a><br>
Log:<br>
[Tooling] Get rid of uses of llvm::Twine::str which is slow. NFC<br>
<br>
Modified:<br>
cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp<br>
<br>
Modified: cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp?rev=343224&r1=343223&r2=343224&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp?rev=343224&r1=343223&r2=343224&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp (original)<br>
+++ cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp Thu Sep 27 07:50:24 2018<br>
@@ -10,6 +10,7 @@<br>
#include "clang/Tooling/Inclusions/HeaderIncludes.h"<br>
#include "clang/Basic/SourceManager.h"<br>
#include "clang/Lex/Lexer.h"<br>
+#include "llvm/Support/FormatVariadic.h"<br>
<br>
namespace clang {<br>
namespace tooling {<br>
@@ -181,7 +182,7 @@ bool IncludeCategoryManager::isMainHeade<br>
llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));<br>
if (FileStem.startswith(HeaderStem) ||<br>
FileStem.startswith_lower(HeaderStem)) {<br>
- llvm::Regex MainIncludeRegex((HeaderStem + Style.IncludeIsMainRegex).str(),<br>
+ llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,<br>
llvm::Regex::IgnoreCase);<br>
if (MainIncludeRegex.match(FileStem))<br>
return true;<br>
@@ -275,8 +276,8 @@ HeaderIncludes::insert(llvm::StringRef I<br>
if ((IsAngled && StringRef(Inc.Name).startswith("<")) ||<br>
(!IsAngled && StringRef(Inc.Name).startswith("\"")))<br>
return llvm::None;<br>
- std::string Quoted = IsAngled ? ("<" + IncludeName + ">").str()<br>
- : ("\"" + IncludeName + "\"").str();<br>
+ std::string Quoted =<br>
+ llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName);<br>
StringRef QuotedName = Quoted;<br>
int Priority = Categories.getIncludePriority(<br>
QuotedName, /*CheckMainHeader=*/FirstIncludeOffset < 0);<br>
@@ -293,7 +294,7 @@ HeaderIncludes::insert(llvm::StringRef I<br>
}<br>
}<br>
assert(InsertOffset <= Code.size());<br>
- std::string NewInclude = ("#include " + QuotedName + "\n").str();<br>
+ std::string NewInclude = llvm::formatv("#include {0}\n", QuotedName);<br></blockquote><div><br>Any idea why formatv is performing better here? Might be worth some consideration/fixing op+.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
// When inserting headers at end of the code, also append '\n' to the code<br>
// if it does not end with '\n'.<br>
// FIXME: when inserting multiple #includes at the end of code, only one<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>