summaryrefslogtreecommitdiff
path: root/lib/TableGen
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-12-04 05:48:06 +0000
committerMatthias Braun <matze@braunis.de>2016-12-04 05:48:06 +0000
commit607c68326d6351e3f88983d67f966ff2f120b344 (patch)
tree9d67a2cd5f7a7f92b7fc70f5a422bfa446b7d483 /lib/TableGen
parent5084450e17cfff583fbb281815e9d55ee51f2008 (diff)
TableGen: Optimize common string concatenation with SmallString
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen')
-rw-r--r--lib/TableGen/Record.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp
index 3e1be837039..a82c38186db 100644
--- a/lib/TableGen/Record.cpp
+++ b/lib/TableGen/Record.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
@@ -839,8 +840,12 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
case STRCONCAT: {
StringInit *LHSs = dyn_cast<StringInit>(LHS);
StringInit *RHSs = dyn_cast<StringInit>(RHS);
- if (LHSs && RHSs)
- return StringInit::get(LHSs->getValue() + RHSs->getValue());
+ if (LHSs && RHSs) {
+ // STRCONCAT is common; Use a SmallString to avoid most heap allocations.
+ SmallString<80> Concat(LHSs->getValue());
+ Concat.append(RHSs->getValue());
+ return StringInit::get(Concat);
+ }
break;
}
case EQ: {