[clang] 4c9c2d6 - [AST] Avoid repeated hash lookups (NFC) (#111327)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 06:55:59 PDT 2024
Author: Kazu Hirata
Date: 2024-10-07T06:55:56-07:00
New Revision: 4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d
URL: https://github.com/llvm/llvm-project/commit/4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d
DIFF: https://github.com/llvm/llvm-project/commit/4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d.diff
LOG: [AST] Avoid repeated hash lookups (NFC) (#111327)
Here I'm splitting up the existing "if" statement into two. Mixing
hasDefinition() and insert() in one "if" condition would be extremely
confusing as hasDefinition() doesn't change anything while insert()
does.
Added:
Modified:
clang/lib/AST/CXXInheritance.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 25de2a20a7f3b7..eb265a872c1259 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -259,12 +259,10 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
BaseRecord = TD->getTemplatedDecl();
}
if (BaseRecord) {
- if (!BaseRecord->hasDefinition() ||
- VisitedDependentRecords.count(BaseRecord)) {
+ if (!BaseRecord->hasDefinition())
+ BaseRecord = nullptr;
+ else if (!VisitedDependentRecords.insert(BaseRecord).second)
BaseRecord = nullptr;
- } else {
- VisitedDependentRecords.insert(BaseRecord);
- }
}
} else {
BaseRecord = cast<CXXRecordDecl>(
More information about the cfe-commits
mailing list