зеркало из https://github.com/microsoft/clang-1.git
only do one DenseMap lookup instead of two (one to find out if there is
already an entry and one to insert). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65030 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
ba1bd5c54d
Коммит
f82328852c
|
@ -561,19 +561,19 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
|
||||||
|
|
||||||
// Insert this declaration into the map.
|
// Insert this declaration into the map.
|
||||||
StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(LookupPtr.getPointer());
|
StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(LookupPtr.getPointer());
|
||||||
StoredDeclsMap::iterator Pos = Map->find(D->getDeclName());
|
std::vector<NamedDecl *> &DeclNameEntries = (*Map)[D->getDeclName()];
|
||||||
if (Pos == Map->end()) {
|
if (DeclNameEntries.empty()) {
|
||||||
(*Map)[D->getDeclName()].push_back(D);
|
DeclNameEntries.push_back(D);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MayBeRedeclaration) {
|
if (MayBeRedeclaration) {
|
||||||
// Determine if this declaration is actually a redeclaration.
|
// Determine if this declaration is actually a redeclaration.
|
||||||
std::vector<NamedDecl *>::iterator Redecl
|
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),
|
std::bind1st(std::mem_fun(&NamedDecl::declarationReplaces),
|
||||||
D));
|
D));
|
||||||
if (Redecl != Pos->second.end()) {
|
if (Redecl != DeclNameEntries.end()) {
|
||||||
*Redecl = D;
|
*Redecl = D;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -582,14 +582,14 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
|
||||||
// Put this declaration into the appropriate slot.
|
// Put this declaration into the appropriate slot.
|
||||||
if (isa<UsingDirectiveDecl>(D) ||
|
if (isa<UsingDirectiveDecl>(D) ||
|
||||||
D->getIdentifierNamespace() == Decl::IDNS_Tag ||
|
D->getIdentifierNamespace() == Decl::IDNS_Tag ||
|
||||||
Pos->second.empty())
|
DeclNameEntries.empty())
|
||||||
Pos->second.push_back(D);
|
DeclNameEntries.push_back(D);
|
||||||
else if (Pos->second.back()->getIdentifierNamespace() == Decl::IDNS_Tag) {
|
else if (DeclNameEntries.back()->getIdentifierNamespace() == Decl::IDNS_Tag) {
|
||||||
NamedDecl *TagD = Pos->second.back();
|
NamedDecl *TagD = DeclNameEntries.back();
|
||||||
Pos->second.back() = D;
|
DeclNameEntries.back() = D;
|
||||||
Pos->second.push_back(TagD);
|
DeclNameEntries.push_back(TagD);
|
||||||
} else
|
} else
|
||||||
Pos->second.push_back(D);
|
DeclNameEntries.push_back(D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
|
/// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
|
||||||
|
|
Загрузка…
Ссылка в новой задаче