Skip to content

Commit e579632

Browse files
authored
[clang] Avoid unnecessary call to clang::NamespaceDecl::isRedundantInlineQualifierFor(). (llvm#115196)
We observed 2X slowdown in lldb's expression evaluation with llvm#109147 in some cases. It turns out that calling `isRedundantInlineQualifierFor` is quite expensive. Using short-circuit evaluation in the if statement to avoid unnecessary calls to that function.
1 parent 0dbdb32 commit e579632

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,13 +1738,12 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream &OS,
17381738

17391739
// Suppress inline namespace if it doesn't make the result ambiguous.
17401740
if (Ctx->isInlineNamespace() && NameInScope) {
1741-
bool isRedundant =
1742-
cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(NameInScope);
17431741
if (P.SuppressInlineNamespace ==
17441742
PrintingPolicy::SuppressInlineNamespaceMode::All ||
17451743
(P.SuppressInlineNamespace ==
17461744
PrintingPolicy::SuppressInlineNamespaceMode::Redundant &&
1747-
isRedundant)) {
1745+
cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(
1746+
NameInScope))) {
17481747
continue;
17491748
}
17501749
}

0 commit comments

Comments
 (0)