From 86f8bacaebd13e60f9aa0e7c373ec7505d54ae7f Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 Oct 2014 15:32:48 +0000 Subject: [PATCH] Reduce double set lookups. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219504 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/VTableBuilder.cpp | 3 +-- lib/CodeGen/CGOpenMPRuntime.cpp | 3 +-- lib/Frontend/SerializedDiagnosticPrinter.cpp | 6 ++---- lib/Sema/SemaOpenMP.cpp | 3 +-- lib/StaticAnalyzer/Core/ExplodedGraph.cpp | 9 ++------- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp index 7007c9593d..43a0fb7d75 100644 --- a/lib/AST/VTableBuilder.cpp +++ b/lib/AST/VTableBuilder.cpp @@ -3302,9 +3302,8 @@ findPathForVPtr(ASTContext &Context, const ASTRecordLayout &MostDerivedLayout, if (!B.isVirtual()) NewOffset = Offset + Layout.getBaseClassOffset(Base); else { - if (VBasesSeen.count(Base)) + if (!VBasesSeen.insert(Base)) return false; - VBasesSeen.insert(Base); NewOffset = MostDerivedLayout.getVBaseClassOffset(Base); } FullPath.push_back(Base); diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index 08b2dad102..b3e5c1123c 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -232,8 +232,7 @@ llvm::Value *CGOpenMPRuntime::GetOpenMPThreadID(CodeGenFunction &CGF, void CGOpenMPRuntime::FunctionFinished(CodeGenFunction &CGF) { assert(CGF.CurFn && "No function in current CodeGenFunction."); - if (OpenMPLocThreadIDMap.count(CGF.CurFn)) - OpenMPLocThreadIDMap.erase(CGF.CurFn); + OpenMPLocThreadIDMap.erase(CGF.CurFn); } llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() { diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp index 15f78d2525..3d6e7578c7 100644 --- a/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -472,11 +472,9 @@ void SDiagsWriter::EmitMetaBlock() { } unsigned SDiagsWriter::getEmitCategory(unsigned int category) { - if (State->Categories.count(category)) + if (!State->Categories.insert(category).second) return category; - - State->Categories.insert(category); - + // We use a local version of 'Record' so that we can be generating // another record when we lazily generate one for the category entry. RecordData Record; diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 6e43a3d4b2..23f5f13e8f 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -2483,8 +2483,7 @@ static bool CheckOpenMPIterationSpace( // that is the increment of the associated for-loop. // Exclude loop var from the list of variables with implicitly defined data // sharing attributes. - while (VarsWithImplicitDSA.count(Var) > 0) - VarsWithImplicitDSA.erase(Var); + VarsWithImplicitDSA.erase(Var); // OpenMP [2.14.1.1, Data-sharing Attribute Rules for Variables Referenced in // a Construct, C/C++]. diff --git a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp index c0bc902c49..010d26e48e 100644 --- a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -365,12 +365,9 @@ ExplodedGraph::trim(ArrayRef Sinks, const ExplodedNode *N = WL1.pop_back_val(); // Have we already visited this node? If so, continue to the next one. - if (Pass1.count(N)) + if (!Pass1.insert(N).second) continue; - // Otherwise, mark this node as visited. - Pass1.insert(N); - // If this is a root enqueue it to the second worklist. if (N->Preds.empty()) { WL2.push_back(N); @@ -378,9 +375,7 @@ ExplodedGraph::trim(ArrayRef Sinks, } // Visit our predecessors and enqueue them. - for (ExplodedNode::pred_iterator I = N->Preds.begin(), E = N->Preds.end(); - I != E; ++I) - WL1.push_back(*I); + WL1.append(N->Preds.begin(), N->Preds.end()); } // We didn't hit a root? Return with a null pointer for the new graph. -- 2.40.0