summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-19 07:05:16 +0000
committerChris Lattner <sabre@nondot.org>2009-02-19 07:05:16 +0000
commit124bb197a7580df57a491ab1f8f766000f492e9d (patch)
tree156460f0203fd1a4ed357f746cc9e55aac825d87 /clang
parent74c04eb99e1a5038923ea894207a51fce35384f9 (diff)
downloadbcm5719-llvm-124bb197a7580df57a491ab1f8f766000f492e9d.tar.gz
bcm5719-llvm-124bb197a7580df57a491ab1f8f766000f492e9d.zip
only do one DenseMap lookup instead of two (one to find out if there is
already an entry and one to insert). llvm-svn: 65030
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/DeclBase.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index c03c36048a2..d244637af7f 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -561,19 +561,19 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
// Insert this declaration into the map.
StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(LookupPtr.getPointer());
- StoredDeclsMap::iterator Pos = Map->find(D->getDeclName());
- if (Pos == Map->end()) {
- (*Map)[D->getDeclName()].push_back(D);
+ std::vector<NamedDecl *> &DeclNameEntries = (*Map)[D->getDeclName()];
+ if (DeclNameEntries.empty()) {
+ DeclNameEntries.push_back(D);
return;
}
if (MayBeRedeclaration) {
// Determine if this declaration is actually a redeclaration.
std::vector<NamedDecl *>::iterator Redecl
- = std::find_if(Pos->second.begin(), Pos->second.end(),
+ = std::find_if(DeclNameEntries.begin(), DeclNameEntries.end(),
std::bind1st(std::mem_fun(&NamedDecl::declarationReplaces),
D));
- if (Redecl != Pos->second.end()) {
+ if (Redecl != DeclNameEntries.end()) {
*Redecl = D;
return;
}
@@ -582,14 +582,14 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
// Put this declaration into the appropriate slot.
if (isa<UsingDirectiveDecl>(D) ||
D->getIdentifierNamespace() == Decl::IDNS_Tag ||
- Pos->second.empty())
- Pos->second.push_back(D);
- else if (Pos->second.back()->getIdentifierNamespace() == Decl::IDNS_Tag) {
- NamedDecl *TagD = Pos->second.back();
- Pos->second.back() = D;
- Pos->second.push_back(TagD);
+ DeclNameEntries.empty())
+ DeclNameEntries.push_back(D);
+ else if (DeclNameEntries.back()->getIdentifierNamespace() == Decl::IDNS_Tag) {
+ NamedDecl *TagD = DeclNameEntries.back();
+ DeclNameEntries.back() = D;
+ DeclNameEntries.push_back(TagD);
} else
- Pos->second.push_back(D);
+ DeclNameEntries.push_back(D);
}
/// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
OpenPOWER on IntegriCloud