[llvm] [TableGen] Avoid repeated hash lookps (NFC) (PR #108138)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 20:11:34 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/108138.diff
1 Files Affected:
- (modified) llvm/utils/TableGen/DAGISelMatcherEmitter.cpp (+3-3)
``````````diff
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 1b93e3d5e3b705..a14cc3d6b844c5 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -71,9 +71,9 @@ class MatcherTableEmitter {
MapVector<std::string, unsigned, StringMap<unsigned>> VecPatterns;
unsigned getPatternIdxFromTable(std::string &&P, std::string &&include_loc) {
- const auto It = VecPatterns.find(P);
- if (It == VecPatterns.end()) {
- VecPatterns.insert(std::pair(std::move(P), VecPatterns.size()));
+ const auto [It, Inserted] =
+ VecPatterns.try_emplace(std::move(P), VecPatterns.size());
+ if (Inserted) {
VecIncludeStrings.push_back(std::move(include_loc));
return VecIncludeStrings.size() - 1;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/108138
More information about the llvm-commits
mailing list