Author: Kazu Hirata
Date: 2024-09-07T11:23:26-07:00
New Revision: 9c86a7e9ec716fb54a0b74e13af12cb655723e53

URL: 
https://github.com/llvm/llvm-project/commit/9c86a7e9ec716fb54a0b74e13af12cb655723e53
DIFF: 
https://github.com/llvm/llvm-project/commit/9c86a7e9ec716fb54a0b74e13af12cb655723e53.diff

LOG: [AST] Avoid repeated hash lookups (NFC) (#107709)

While I am at it, I'm renaming Cache to UniqueDecls and removing
TotalNum in favor of UniqueDecls.size().

Added: 
    

Modified: 
    clang/lib/AST/OpenMPClause.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 7e73c076239410..eb15aa84406901 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1125,16 +1125,12 @@ unsigned 
OMPClauseMappableExprCommon::getComponentsTotalNumber(
 
 unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber(
     ArrayRef<const ValueDecl *> Declarations) {
-  unsigned TotalNum = 0u;
-  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
+  llvm::SmallPtrSet<const ValueDecl *, 8> UniqueDecls;
   for (const ValueDecl *D : Declarations) {
     const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
-    if (Cache.count(VD))
-      continue;
-    ++TotalNum;
-    Cache.insert(VD);
+    UniqueDecls.insert(VD);
   }
-  return TotalNum;
+  return UniqueDecls.size();
 }
 
 OMPMapClause *OMPMapClause::Create(


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to