Reduce duplicated hash map lookups.

llvm-svn: 162361
This commit is contained in:
Benjamin Kramer 2012-08-22 15:37:55 +00:00
parent 0c6c405e23
commit fc6eb7d383
5 changed files with 11 additions and 23 deletions

View File

@ -779,28 +779,24 @@ static unsigned ComputeVMIClassTypeInfoFlags(const CXXBaseSpecifier *Base,
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (Base->isVirtual()) {
if (Bases.VirtualBases.count(BaseDecl)) {
// Mark the virtual base as seen.
if (!Bases.VirtualBases.insert(BaseDecl)) {
// If this virtual base has been seen before, then the class is diamond
// shaped.
Flags |= RTTIBuilder::VMI_DiamondShaped;
} else {
if (Bases.NonVirtualBases.count(BaseDecl))
Flags |= RTTIBuilder::VMI_NonDiamondRepeat;
// Mark the virtual base as seen.
Bases.VirtualBases.insert(BaseDecl);
}
} else {
if (Bases.NonVirtualBases.count(BaseDecl)) {
// Mark the non-virtual base as seen.
if (!Bases.NonVirtualBases.insert(BaseDecl)) {
// If this non-virtual base has been seen before, then the class has non-
// diamond shaped repeated inheritance.
Flags |= RTTIBuilder::VMI_NonDiamondRepeat;
} else {
if (Bases.VirtualBases.count(BaseDecl))
Flags |= RTTIBuilder::VMI_NonDiamondRepeat;
// Mark the non-virtual base as seen.
Bases.NonVirtualBases.insert(BaseDecl);
}
}

View File

@ -1051,12 +1051,10 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName,
// Lookup the entry, lazily creating it if necessary.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry) {
if (WeakRefReferences.count(Entry)) {
if (WeakRefReferences.erase(Entry)) {
const FunctionDecl *FD = cast_or_null<FunctionDecl>(D.getDecl());
if (FD && !FD->hasAttr<WeakAttr>())
Entry->setLinkage(llvm::Function::ExternalLinkage);
WeakRefReferences.erase(Entry);
}
if (Entry->getType()->getElementType() == Ty)
@ -1197,11 +1195,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
// Lookup the entry, lazily creating it if necessary.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry) {
if (WeakRefReferences.count(Entry)) {
if (WeakRefReferences.erase(Entry)) {
if (D && !D->hasAttr<WeakAttr>())
Entry->setLinkage(llvm::Function::ExternalLinkage);
WeakRefReferences.erase(Entry);
}
if (UnnamedAddr)

View File

@ -1491,8 +1491,8 @@ static void CollectClassPropertyImplementations(ObjCContainerDecl *CDecl,
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
ObjCPropertyDecl *Prop = *P;
if (!PropMap.count(Prop->getIdentifier()))
PropMap[Prop->getIdentifier()] = Prop;
// Insert into PropMap if not there already.
PropMap.insert(std::make_pair(Prop->getIdentifier(), Prop));
}
// scan through protocol's protocols.
for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),

View File

@ -2631,7 +2631,7 @@ void ASTReader::makeModuleVisible(Module *Mod,
for (unsigned I = 0, N = Mod->Imports.size(); I != N; ++I) {
Module *Imported = Mod->Imports[I];
if (Visited.count(Imported))
if (!Visited.insert(Imported))
continue;
bool Acceptable = UnrestrictedWildcard;
@ -2649,7 +2649,6 @@ void ASTReader::makeModuleVisible(Module *Mod,
if (!Acceptable)
continue;
Visited.insert(Imported);
Stack.push_back(Imported);
}
}

View File

@ -2207,10 +2207,8 @@ namespace {
if (!D)
return;
if (Deserialized.count(D)) {
Deserialized.erase(D);
if (Deserialized.erase(D))
Chain.push_back(D);
}
}
void searchForID(ModuleFile &M, GlobalDeclID GlobalID) {
@ -2331,9 +2329,8 @@ namespace {
void add(ObjCCategoryDecl *Cat) {
// Only process each category once.
if (!Deserialized.count(Cat))
if (!Deserialized.erase(Cat))
return;
Deserialized.erase(Cat);
// Check for duplicate categories.
if (Cat->getDeclName()) {