[clang] 42e0ee4 - [Sema] Avoid repeated hash lookups (NFC) (#127301)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 15 01:36:19 PST 2025


Author: Kazu Hirata
Date: 2025-02-15T01:36:16-08:00
New Revision: 42e0ee4d7eaafd86a27418cd8c752229ce90c8e2

URL: https://github.com/llvm/llvm-project/commit/42e0ee4d7eaafd86a27418cd8c752229ce90c8e2
DIFF: https://github.com/llvm/llvm-project/commit/42e0ee4d7eaafd86a27418cd8c752229ce90c8e2.diff

LOG: [Sema] Avoid repeated hash lookups (NFC) (#127301)

Added: 
    

Modified: 
    clang/lib/Sema/SemaDecl.cpp

Removed: 
    


################################################################################
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


        


More information about the cfe-commits mailing list