[clang] [Sema] Avoid repeated hash lookups (NFC) (PR #111090)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 19:59:42 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111090
None
>From cd8fc9cd8e9ef757d129b3bbdddaeaf163d08d51 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 3 Oct 2024 08:47:32 -0700
Subject: [PATCH] [Sema] Avoid repeated hash lookups (NFC)
---
clang/lib/Sema/SemaLambda.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index c2b35856111f3b..aeb20299b714a3 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -423,11 +423,11 @@ bool Sema::DiagnoseInvalidExplicitObjectParameterInLambda(
// is an empty cast path for the method stored in the context (signalling that
// we've already diagnosed it) and then just not building the call, but that
// doesn't really seem any simpler than diagnosing it at the call site...
- if (auto It = Context.LambdaCastPaths.find(Method);
- It != Context.LambdaCastPaths.end())
+ auto [It, Inserted] = Context.LambdaCastPaths.try_emplace(Method);
+ if (!Inserted)
return It->second.empty();
- CXXCastPath &Path = Context.LambdaCastPaths[Method];
+ CXXCastPath &Path = It->second;
CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
/*DetectVirtual=*/false);
if (!IsDerivedFrom(RD->getLocation(), ExplicitObjectParameterType, LambdaType,
More information about the cfe-commits
mailing list