Skip to content

Commit

Permalink
[mlir] Prefer StringRef::substr to slice (NFC) (#113788)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
kazutakahirata authored Oct 27, 2024
1 parent 45c84d5 commit 5287a9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions mlir/include/mlir/Support/IndentedOstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ inline void mlir::raw_indented_ostream::write_impl(const char *ptr,
break;
}

auto split =
std::make_pair(str.slice(0, idx), str.slice(idx + 1, StringRef::npos));
auto split = std::make_pair(str.substr(0, idx), str.substr(idx + 1));
// Print empty new line without spaces if line only has spaces and no extra
// prefix is requested.
if (!split.first.ltrim().empty() || !currentExtraPrefix.empty())
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Query/QueryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ QueryRef QueryParser::doParse() {
if (!matcher) {
return makeInvalidQueryFromDiagnostics(diag);
}
auto actualSource = origMatcherSource.slice(0, origMatcherSource.size() -
matcherSource.size());
auto actualSource = origMatcherSource.substr(0, origMatcherSource.size() -
matcherSource.size());
QueryRef query = new MatchQuery(actualSource, *matcher);
query->remainingContent = matcherSource;
return query;
Expand Down

0 comments on commit 5287a9b

Please sign in to comment.