[clang] [Sema] Avoid repeated hash lookups (NFC) (PR #110951)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 20:15:34 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110951

None

>From 6e37d7fac860490dd491afff51b6ec26c45b4594 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 2 Oct 2024 07:01:33 -0700
Subject: [PATCH] [Sema] Avoid repeated hash lookups (NFC)

---
 clang/lib/Sema/JumpDiagnostics.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 8af36d5c24e3d2..00fdffca4e9ea9 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -761,8 +761,7 @@ void JumpScopeChecker::VerifyIndirectJumps() {
       if (CHECK_PERMISSIVE(!LabelAndGotoScopes.count(IG)))
         continue;
       unsigned IGScope = LabelAndGotoScopes[IG];
-      if (!JumpScopesMap.contains(IGScope))
-        JumpScopesMap[IGScope] = IG;
+      JumpScopesMap.try_emplace(IGScope, IG);
     }
     JumpScopes.reserve(JumpScopesMap.size());
     for (auto &Pair : JumpScopesMap)



More information about the cfe-commits mailing list