Skip to content

Commit 2997a67

Browse files
[Sema] Avoid repeated hash lookups (NFC) (llvm#111090)
1 parent 8305e9f commit 2997a67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/lib/Sema/SemaLambda.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,11 @@ bool Sema::DiagnoseInvalidExplicitObjectParameterInLambda(
423423
// is an empty cast path for the method stored in the context (signalling that
424424
// we've already diagnosed it) and then just not building the call, but that
425425
// doesn't really seem any simpler than diagnosing it at the call site...
426-
if (auto It = Context.LambdaCastPaths.find(Method);
427-
It != Context.LambdaCastPaths.end())
426+
auto [It, Inserted] = Context.LambdaCastPaths.try_emplace(Method);
427+
if (!Inserted)
428428
return It->second.empty();
429429

430-
CXXCastPath &Path = Context.LambdaCastPaths[Method];
430+
CXXCastPath &Path = It->second;
431431
CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
432432
/*DetectVirtual=*/false);
433433
if (!IsDerivedFrom(RD->getLocation(), ExplicitObjectParameterType, LambdaType,

0 commit comments

Comments
 (0)