Skip to content

Commit 5287a9b

Browse files
[mlir] Prefer StringRef::substr to slice (NFC) (#113788)
I'm planning to migrate StringRef to std::string_view eventually. Since std::string_view does not have slice, this patch migrates: slice(0, N) to substr(0, N) slice(N, StringRef::npos) to substr(N)
1 parent 45c84d5 commit 5287a9b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

mlir/include/mlir/Support/IndentedOstream.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ inline void mlir::raw_indented_ostream::write_impl(const char *ptr,
166166
break;
167167
}
168168

169-
auto split =
170-
std::make_pair(str.slice(0, idx), str.slice(idx + 1, StringRef::npos));
169+
auto split = std::make_pair(str.substr(0, idx), str.substr(idx + 1));
171170
// Print empty new line without spaces if line only has spaces and no extra
172171
// prefix is requested.
173172
if (!split.first.ltrim().empty() || !currentExtraPrefix.empty())

mlir/lib/Query/QueryParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ QueryRef QueryParser::doParse() {
181181
if (!matcher) {
182182
return makeInvalidQueryFromDiagnostics(diag);
183183
}
184-
auto actualSource = origMatcherSource.slice(0, origMatcherSource.size() -
185-
matcherSource.size());
184+
auto actualSource = origMatcherSource.substr(0, origMatcherSource.size() -
185+
matcherSource.size());
186186
QueryRef query = new MatchQuery(actualSource, *matcher);
187187
query->remainingContent = matcherSource;
188188
return query;

0 commit comments

Comments
 (0)