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

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 9 11:36:26 PST 2025


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

None

>From cc8c559955ba689c7278b1e18118170fb6edf027 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 9 Feb 2025 09:17:07 -0800
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 4b92d67e49d7d73..ffbb9bc0bfe7cd0 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -786,8 +786,7 @@ void JumpScopeChecker::VerifyIndirectJumps() {
     if (CHECK_PERMISSIVE(!LabelAndGotoScopes.count(TheLabel->getStmt())))
       continue;
     unsigned LabelScope = LabelAndGotoScopes[TheLabel->getStmt()];
-    if (!TargetScopes.contains(LabelScope))
-      TargetScopes[LabelScope] = TheLabel;
+    TargetScopes.try_emplace(LabelScope, TheLabel);
   }
 
   // For each target scope, make sure it's trivially reachable from



More information about the cfe-commits mailing list