aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-04-12 15:22:25 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-04-12 15:22:25 +0000
commit3bbffd549c76dfeb3c8d7c73860736a6523cde92 (patch)
treeffca9456b4471ac2b5322615d5cc2f45bb8b82d8
parent67d080dafa74c7d126da522fec333a6e52a5ae35 (diff)
Sema: Give a typically small DenseMap some inline capacity.
Also reflow code a bit, no change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179382 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Sema/Template.h8
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp7
2 files changed, 7 insertions, 8 deletions
diff --git a/include/clang/Sema/Template.h b/include/clang/Sema/Template.h
index 492e5800bd..8ee8f35ccb 100644
--- a/include/clang/Sema/Template.h
+++ b/include/clang/Sema/Template.h
@@ -187,10 +187,10 @@ namespace clang {
/// this template instantiation.
Sema &SemaRef;
- typedef llvm::DenseMap<const Decl *,
- llvm::PointerUnion<Decl *, DeclArgumentPack *> >
- LocalDeclsMap;
-
+ typedef llvm::SmallDenseMap<
+ const Decl *, llvm::PointerUnion<Decl *, DeclArgumentPack *>, 4>
+ LocalDeclsMap;
+
/// \brief A mapping from local declarations that occur
/// within a template to their instantiations.
///
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index f755b8ca45..7ef04e964d 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2701,11 +2701,10 @@ void LocalInstantiationScope::InstantiatedLocal(const Decl *D, Decl *Inst) {
llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
if (Stored.isNull())
Stored = Inst;
- else if (Stored.is<Decl *>()) {
+ else if (DeclArgumentPack *Pack = Stored.dyn_cast<DeclArgumentPack *>())
+ Pack->push_back(Inst);
+ else
assert(Stored.get<Decl *>() == Inst && "Already instantiated this local");
- Stored = Inst;
- } else
- LocalDecls[D].get<DeclArgumentPack *>()->push_back(Inst);
}
void LocalInstantiationScope::InstantiatedLocalPackArg(const Decl *D,