[Mlir-commits] [mlir] 29a4561 - [mlir] Use std::string::find with std::string_view (NFC) (#139683)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue May 13 07:13:16 PDT 2025
Author: Kazu Hirata
Date: 2025-05-13T07:13:10-07:00
New Revision: 29a45619f1f8f0e0f0edd4937cf31827d1a4c4d4
URL: https://github.com/llvm/llvm-project/commit/29a45619f1f8f0e0f0edd4937cf31827d1a4c4d4
DIFF: https://github.com/llvm/llvm-project/commit/29a45619f1f8f0e0f0edd4937cf31827d1a4c4d4.diff
LOG: [mlir] Use std::string::find with std::string_view (NFC) (#139683)
Starting with C++17, std::string::find accepts anything that can be
converted to std::string_view, including StringRef, allowing us to
avoid creating temporary instances of std::string.
Added:
Modified:
mlir/lib/TableGen/Predicate.cpp
Removed:
################################################################################
diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp
index e5cfc074d09f4..11afa27caf709 100644
--- a/mlir/lib/TableGen/Predicate.cpp
+++ b/mlir/lib/TableGen/Predicate.cpp
@@ -141,14 +141,14 @@ static void performSubstitutions(std::string &str,
ArrayRef<Subst> substitutions) {
// Apply all parent substitutions from innermost to outermost.
for (const auto &subst : llvm::reverse(substitutions)) {
- auto pos = str.find(std::string(subst.first));
+ auto pos = str.find(subst.first);
while (pos != std::string::npos) {
str.replace(pos, subst.first.size(), std::string(subst.second));
// Skip the newly inserted substring, which itself may consider the
// pattern to match.
pos += subst.second.size();
// Find the next possible match position.
- pos = str.find(std::string(subst.first), pos);
+ pos = str.find(subst.first, pos);
}
}
}
More information about the Mlir-commits
mailing list