[clang] [CodeGen] Avoid repeated hash lookups (NFC) (PR #126672)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 22:03:50 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/126672
None
>From 170f0f3c53a64714b8d1257516a910d644b28992 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 10 Feb 2025 08:00:20 -0800
Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC)
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index cafaaa364cb7630..b679d63874b3bbe 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1457,14 +1457,13 @@ void CGOpenMPRuntime::functionFinished(CodeGenFunction &CGF) {
clearLocThreadIdInsertPt(CGF);
OpenMPLocThreadIDMap.erase(CGF.CurFn);
}
- if (FunctionUDRMap.count(CGF.CurFn) > 0) {
- for(const auto *D : FunctionUDRMap[CGF.CurFn])
+ if (auto I = FunctionUDRMap.find(CGF.CurFn); I != FunctionUDRMap.end()) {
+ for (const auto *D : I->second)
UDRMap.erase(D);
- FunctionUDRMap.erase(CGF.CurFn);
+ FunctionUDRMap.erase(I);
}
- auto I = FunctionUDMMap.find(CGF.CurFn);
- if (I != FunctionUDMMap.end()) {
- for(const auto *D : I->second)
+ if (auto I = FunctionUDMMap.find(CGF.CurFn); I != FunctionUDMMap.end()) {
+ for (const auto *D : I->second)
UDMMap.erase(D);
FunctionUDMMap.erase(I);
}
More information about the cfe-commits
mailing list