Skip to content

Commit 29a4561

Browse files
[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.
1 parent 69ce681 commit 29a4561

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mlir/lib/TableGen/Predicate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ static void performSubstitutions(std::string &str,
141141
ArrayRef<Subst> substitutions) {
142142
// Apply all parent substitutions from innermost to outermost.
143143
for (const auto &subst : llvm::reverse(substitutions)) {
144-
auto pos = str.find(std::string(subst.first));
144+
auto pos = str.find(subst.first);
145145
while (pos != std::string::npos) {
146146
str.replace(pos, subst.first.size(), std::string(subst.second));
147147
// Skip the newly inserted substring, which itself may consider the
148148
// pattern to match.
149149
pos += subst.second.size();
150150
// Find the next possible match position.
151-
pos = str.find(std::string(subst.first), pos);
151+
pos = str.find(subst.first, pos);
152152
}
153153
}
154154
}

0 commit comments

Comments
 (0)