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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254221 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2015-11-28 08:23:02 +00:00
parent feed6dbc9f
commit b51ae5ef11

View File

@ -14,6 +14,7 @@
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
@ -873,14 +874,14 @@ std::string PatternToMatch::getPredicateCheck() const {
// Sort so that different orders get canonicalized to the same string. // Sort so that different orders get canonicalized to the same string.
std::sort(PredicateRecs.begin(), PredicateRecs.end(), LessRecord()); std::sort(PredicateRecs.begin(), PredicateRecs.end(), LessRecord());
std::string PredicateCheck; SmallString<128> PredicateCheck;
for (Record *Pred : PredicateRecs) { for (Record *Pred : PredicateRecs) {
if (!PredicateCheck.empty()) if (!PredicateCheck.empty())
PredicateCheck += " && "; PredicateCheck += " && ";
PredicateCheck += "(" + Pred->getValueAsString("CondString") + ")"; PredicateCheck += "(" + Pred->getValueAsString("CondString") + ")";
} }
return PredicateCheck; return PredicateCheck.str();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//