[llvm] 7dfaedf - [TableGen] Avoid repeated hash lookups (NFC) (#108138)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 06:40:02 PDT 2024


Author: Kazu Hirata
Date: 2024-09-11T06:39:58-07:00
New Revision: 7dfaedf86127620821da7d31bf08fe1403f19ffe

URL: https://github.com/llvm/llvm-project/commit/7dfaedf86127620821da7d31bf08fe1403f19ffe
DIFF: https://github.com/llvm/llvm-project/commit/7dfaedf86127620821da7d31bf08fe1403f19ffe.diff

LOG: [TableGen] Avoid repeated hash lookups (NFC) (#108138)

Added: 
    

Modified: 
    llvm/utils/TableGen/DAGISelMatcherEmitter.cpp

Removed: 
    


################################################################################
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