[Mlir-commits] [mlir] [mlir] Use std::string::find with std::string_view (NFC) (PR #139683)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue May 13 00:39:59 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/139683.diff
1 Files Affected:
- (modified) mlir/lib/TableGen/Predicate.cpp (+2-2)
``````````diff
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);
}
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/139683
More information about the Mlir-commits
mailing list