Skip to content

Commit 9c86a7e

Browse files
[AST] Avoid repeated hash lookups (NFC) (llvm#107709)
While I am at it, I'm renaming Cache to UniqueDecls and removing TotalNum in favor of UniqueDecls.size().
1 parent 6f6100f commit 9c86a7e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

clang/lib/AST/OpenMPClause.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,16 +1125,12 @@ unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber(
11251125

11261126
unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber(
11271127
ArrayRef<const ValueDecl *> Declarations) {
1128-
unsigned TotalNum = 0u;
1129-
llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
1128+
llvm::SmallPtrSet<const ValueDecl *, 8> UniqueDecls;
11301129
for (const ValueDecl *D : Declarations) {
11311130
const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
1132-
if (Cache.count(VD))
1133-
continue;
1134-
++TotalNum;
1135-
Cache.insert(VD);
1131+
UniqueDecls.insert(VD);
11361132
}
1137-
return TotalNum;
1133+
return UniqueDecls.size();
11381134
}
11391135

11401136
OMPMapClause *OMPMapClause::Create(

0 commit comments

Comments
 (0)