r219504 - Reduce double set lookups. NFC.

Benjamin Kramer benny.kra at googlemail.com
Fri Oct 10 08:32:49 PDT 2014


Author: d0k
Date: Fri Oct 10 10:32:48 2014
New Revision: 219504

URL: http://llvm.org/viewvc/llvm-project?rev=219504&view=rev
Log:
Reduce double set lookups. NFC.

Modified:
    cfe/trunk/lib/AST/VTableBuilder.cpp
    cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
    cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=219504&r1=219503&r2=219504&view=diff
==============================================================================
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Fri Oct 10 10:32:48 2014
@@ -3302,9 +3302,8 @@ findPathForVPtr(ASTContext &Context, con
     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);

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=219504&r1=219503&r2=219504&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Oct 10 10:32:48 2014
@@ -232,8 +232,7 @@ llvm::Value *CGOpenMPRuntime::GetOpenMPT
 
 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() {

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=219504&r1=219503&r2=219504&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Fri Oct 10 10:32:48 2014
@@ -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;

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=219504&r1=219503&r2=219504&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Oct 10 10:32:48 2014
@@ -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++].

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=219504&r1=219503&r2=219504&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Fri Oct 10 10:32:48 2014
@@ -365,12 +365,9 @@ ExplodedGraph::trim(ArrayRef<const NodeT
     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<const NodeT
     }
 
     // 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.





More information about the cfe-commits mailing list