[llvm] r254221 - [TableGen] Use SmallString instead of std::string to build up a string to avoid heap allocations. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 28 00:23:02 PST 2015


Author: ctopper
Date: Sat Nov 28 02:23:02 2015
New Revision: 254221

URL: http://llvm.org/viewvc/llvm-project?rev=254221&view=rev
Log:
[TableGen] Use SmallString instead of std::string to build up a string to avoid heap allocations. NFC

Modified:
    llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=254221&r1=254220&r2=254221&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sat Nov 28 02:23:02 2015
@@ -14,6 +14,7 @@
 
 #include "CodeGenDAGPatterns.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Debug.h"
@@ -873,14 +874,14 @@ std::string PatternToMatch::getPredicate
   // Sort so that different orders get canonicalized to the same string.
   std::sort(PredicateRecs.begin(), PredicateRecs.end(), LessRecord());
 
-  std::string PredicateCheck;
+  SmallString<128> PredicateCheck;
   for (Record *Pred : PredicateRecs) {
     if (!PredicateCheck.empty())
       PredicateCheck += " && ";
     PredicateCheck += "(" + Pred->getValueAsString("CondString") + ")";
   }
 
-  return PredicateCheck;
+  return PredicateCheck.str();
 }
 
 //===----------------------------------------------------------------------===//




More information about the llvm-commits mailing list