[llvm] [TableGen] Avoid repeated hash lookps (NFC) (PR #108138)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 20:11:03 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/108138
None
>From 44bb58edbc77bb3581c04c3ad14b40f94d3d6012 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 10 Sep 2024 07:43:20 -0700
Subject: [PATCH] [TableGen] Avoid repeated hash lookps (NFC)
---
llvm/utils/TableGen/DAGISelMatcherEmitter.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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;
}
More information about the llvm-commits
mailing list