[Mlir-commits] [mlir] [mlir] Prefer StringRef::substr to slice (NFC) (PR #113788)
Kazu Hirata
llvmlistbot at llvm.org
Sat Oct 26 20:39:33 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/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)
>From 66de050cde71e831cfff337dcbebff9e81fc9ed7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 26 Oct 2024 20:32:07 -0700
Subject: [PATCH] [mlir] Prefer StringRef::substr to slice (NFC)
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)
---
mlir/include/mlir/Support/IndentedOstream.h | 3 +--
mlir/lib/Query/QueryParser.cpp | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/mlir/include/mlir/Support/IndentedOstream.h b/mlir/include/mlir/Support/IndentedOstream.h
index 101aa8b631d299..eeab36806c4ee7 100644
--- a/mlir/include/mlir/Support/IndentedOstream.h
+++ b/mlir/include/mlir/Support/IndentedOstream.h
@@ -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())
diff --git a/mlir/lib/Query/QueryParser.cpp b/mlir/lib/Query/QueryParser.cpp
index 13ee931cc5227f..31aead7d403d0d 100644
--- a/mlir/lib/Query/QueryParser.cpp
+++ b/mlir/lib/Query/QueryParser.cpp
@@ -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;
More information about the Mlir-commits
mailing list