https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/127301
None >From 8dc601728da95660090898624f083c64a72ae6aa Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Fri, 14 Feb 2025 02:45:21 -0800 Subject: [PATCH] [Sema] Avoid repeated hash lookups (NFC) --- clang/lib/Sema/SemaDecl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 98c245cdea78f..362df485a025c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -16014,7 +16014,8 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) { llvm::DenseMap<const BlockDecl *, bool> EscapeInfo; auto IsOrNestedInEscapingBlock = [&](const BlockDecl *BD) { - if (auto It = EscapeInfo.find(BD); It != EscapeInfo.end()) + auto [It, Inserted] = EscapeInfo.try_emplace(BD); + if (!Inserted) return It->second; bool R = false; @@ -16027,7 +16028,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) { CurBD = CurBD->getParent()->getInnermostBlockDecl(); } while (CurBD); - return EscapeInfo[BD] = R; + return It->second = R; }; // If the location where 'self' is implicitly retained is inside a escaping _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits