[clang] [CodeGen] Avoid repeated hash lookups (NFC) (PR #107736)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 7 23:41:28 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/107736.diff
1 Files Affected:
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+4-10)
``````````diff
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);
}
}
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/107736
More information about the cfe-commits
mailing list