[Mlir-commits] [mlir] 18b3949 - [TableGen] Avoid repeated hash lookups (NFC) (#108321)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Sep 12 00:51:12 PDT 2024
Author: Kazu Hirata
Date: 2024-09-12T00:51:09-07:00
New Revision: 18b39497957a597a630a8daa4b4691b23f0d52c3
URL: https://github.com/llvm/llvm-project/commit/18b39497957a597a630a8daa4b4691b23f0d52c3
DIFF: https://github.com/llvm/llvm-project/commit/18b39497957a597a630a8daa4b4691b23f0d52c3.diff
LOG: [TableGen] Avoid repeated hash lookups (NFC) (#108321)
Added:
Modified:
mlir/lib/TableGen/CodeGenHelpers.cpp
Removed:
################################################################################
diff --git a/mlir/lib/TableGen/CodeGenHelpers.cpp b/mlir/lib/TableGen/CodeGenHelpers.cpp
index 314b20491460aa..7e7640303a1256 100644
--- a/mlir/lib/TableGen/CodeGenHelpers.cpp
+++ b/mlir/lib/TableGen/CodeGenHelpers.cpp
@@ -258,9 +258,9 @@ std::string StaticVerifierFunctionEmitter::getUniqueName(StringRef kind,
void StaticVerifierFunctionEmitter::collectConstraint(ConstraintMap &map,
StringRef kind,
Constraint constraint) {
- auto *it = map.find(constraint);
- if (it == map.end())
- map.insert({constraint, getUniqueName(kind, map.size())});
+ auto [it, inserted] = map.try_emplace(constraint);
+ if (inserted)
+ it->second = getUniqueName(kind, map.size());
}
void StaticVerifierFunctionEmitter::collectOpConstraints(
More information about the Mlir-commits
mailing list