[clang] [Sema] Avoid repeated hash lookups (NFC) (PR #127301)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 14 21:35:18 PST 2025
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 <kazu at 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
More information about the cfe-commits
mailing list