[clang] [AST] Avoid repeated hash lookups (NFC) (PR #111327)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 6 19:32:01 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/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.
>From f589b84590745c8709f1d9ce0e18c5e13746a27f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 6 Oct 2024 09:25:35 -0700
Subject: [PATCH] [AST] Avoid repeated hash lookups (NFC)
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.
---
clang/lib/AST/CXXInheritance.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
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