[Mlir-commits] [mlir] 5e1e6a6 - [TableGen] Avoid repeated hash lookups (NFC) (#107429)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Sep 5 11:58:07 PDT 2024


Author: Kazu Hirata
Date: 2024-09-05T11:58:03-07:00
New Revision: 5e1e6a689c82aaf2b7af72e074c95889a11d3a78

URL: https://github.com/llvm/llvm-project/commit/5e1e6a689c82aaf2b7af72e074c95889a11d3a78
DIFF: https://github.com/llvm/llvm-project/commit/5e1e6a689c82aaf2b7af72e074c95889a11d3a78.diff

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

Added: 
    

Modified: 
    mlir/lib/TableGen/Pattern.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index afb69e7cc55866..1be0e744ffbc86 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -137,11 +137,10 @@ llvm::StringRef DagNode::getSymbol() const { return node->getNameStr(); }
 
 Operator &DagNode::getDialectOp(RecordOperatorMap *mapper) const {
   llvm::Record *opDef = cast<llvm::DefInit>(node->getOperator())->getDef();
-  auto it = mapper->find(opDef);
-  if (it != mapper->end())
-    return *it->second;
-  return *mapper->try_emplace(opDef, std::make_unique<Operator>(opDef))
-              .first->second;
+  auto [it, inserted] = mapper->try_emplace(opDef);
+  if (inserted)
+    it->second = std::make_unique<Operator>(opDef);
+  return *it->second;
 }
 
 int DagNode::getNumOps() const {


        


More information about the Mlir-commits mailing list