Skip to content

Commit 4c9c2d6

Browse files
[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.
1 parent 1666d13 commit 4c9c2d6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

clang/lib/AST/CXXInheritance.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,10 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
259259
BaseRecord = TD->getTemplatedDecl();
260260
}
261261
if (BaseRecord) {
262-
if (!BaseRecord->hasDefinition() ||
263-
VisitedDependentRecords.count(BaseRecord)) {
262+
if (!BaseRecord->hasDefinition())
263+
BaseRecord = nullptr;
264+
else if (!VisitedDependentRecords.insert(BaseRecord).second)
264265
BaseRecord = nullptr;
265-
} else {
266-
VisitedDependentRecords.insert(BaseRecord);
267-
}
268266
}
269267
} else {
270268
BaseRecord = cast<CXXRecordDecl>(

0 commit comments

Comments
 (0)