Author: Kazu Hirata
Date: 2024-10-04T07:37:11-07:00
New Revision: 2997a67172e0f3752f9f25210d86ba6fa65e63e7

URL: 
https://github.com/llvm/llvm-project/commit/2997a67172e0f3752f9f25210d86ba6fa65e63e7
DIFF: 
https://github.com/llvm/llvm-project/commit/2997a67172e0f3752f9f25210d86ba6fa65e63e7.diff

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

Added: 
    

Modified: 
    clang/lib/Sema/SemaLambda.cpp

Removed: 
    


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


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to