[clang] 13546c2 - [CodeGen] Avoid repeated hash lookups (NFC) (#107736)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 8 01:26:27 PDT 2024
Author: Kazu Hirata
Date: 2024-09-08T01:26:24-07:00
New Revision: 13546c284fc31fa5543b07941e864b9b0aaa8638
URL: https://github.com/llvm/llvm-project/commit/13546c284fc31fa5543b07941e864b9b0aaa8638
DIFF: https://github.com/llvm/llvm-project/commit/13546c284fc31fa5543b07941e864b9b0aaa8638.diff
LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#107736)
Added:
Modified:
clang/lib/CodeGen/CodeGenFunction.h
Removed:
################################################################################
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