[clang] [CodeGen] Avoid repeated hash lookups (NFC) (PR #107736)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 7 23:40:57 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107736
None
>From 4e519d4f71b47513f6da0258e7a27dd71763f312 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 7 Sep 2024 23:27:23 -0700
Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC)
---
clang/lib/CodeGen/CodeGenFunction.h | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 368fc112187ffc..9b93e9673ec5f8 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1143,17 +1143,11 @@ class CodeGenFunction : public CodeGenTypeCache {
/// Copy all the entries in the source map over the corresponding
/// entries in the destination, which must exist.
static void copyInto(const DeclMapTy &Src, DeclMapTy &Dest) {
- for (auto &Pair : Src) {
- if (!Pair.second.isValid()) {
- Dest.erase(Pair.first);
- continue;
- }
-
- auto I = Dest.find(Pair.first);
- if (I != Dest.end())
- I->second = Pair.second;
+ for (auto &[Decl, Addr] : Src) {
+ if (!Addr.isValid())
+ Dest.erase(Decl);
else
- Dest.insert(Pair);
+ Dest.insert_or_assign(Decl, Addr);
}
}
};
More information about the cfe-commits
mailing list