Skip to content

Commit abaa79b

Browse files
[mlir] Use StringRef::ltrim (NFC)
1 parent 782c525 commit abaa79b

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

mlir/lib/Query/Matcher/Parser.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ class Parser::CodeTokenizer {
201201
}
202202

203203
// Consume all leading whitespace from code, except newlines
204-
void consumeWhitespace() {
205-
code = code.drop_while(
206-
[](char c) { return llvm::StringRef(" \t\v\f\r").contains(c); });
207-
}
204+
void consumeWhitespace() { code = code.ltrim(" \t\v\f\r"); }
208205

209206
// Returns the current location in the source code
210207
SourceLocation currentLocation() {

mlir/lib/Query/QueryParser.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ namespace mlir::query {
1616
// is found before end, return StringRef(). begin is adjusted to exclude the
1717
// lexed region.
1818
llvm::StringRef QueryParser::lexWord() {
19-
line = line.drop_while([](char c) {
20-
// Don't trim newlines.
21-
return llvm::StringRef(" \t\v\f\r").contains(c);
22-
});
19+
// Don't trim newlines.
20+
line = line.ltrim(" \t\v\f\r");
2321

2422
if (line.empty())
2523
// Even though the line is empty, it contains a pointer and
@@ -91,8 +89,7 @@ struct QueryParser::LexOrCompleteWord {
9189

9290
QueryRef QueryParser::endQuery(QueryRef queryRef) {
9391
llvm::StringRef extra = line;
94-
llvm::StringRef extraTrimmed = extra.drop_while(
95-
[](char c) { return llvm::StringRef(" \t\v\f\r").contains(c); });
92+
llvm::StringRef extraTrimmed = extra.ltrim(" \t\v\f\r");
9693

9794
if ((!extraTrimmed.empty() && extraTrimmed[0] == '\n') ||
9895
(extraTrimmed.size() >= 2 && extraTrimmed[0] == '\r' &&

mlir/lib/TableGen/Class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ MethodBody::MethodBody(bool declOnly)
113113
: declOnly(declOnly), stringOs(body), os(stringOs) {}
114114

115115
void MethodBody::writeTo(raw_indented_ostream &os) const {
116-
auto bodyRef = StringRef(body).drop_while([](char c) { return c == '\n'; });
116+
auto bodyRef = StringRef(body).ltrim('\n');
117117
os << bodyRef;
118118
if (bodyRef.empty())
119119
return;

mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ lsp::extractSourceDocComment(llvm::SourceMgr &sourceMgr, SMLoc loc) {
103103
break;
104104

105105
// Extract the document string from the comment.
106-
commentLines.push_back(line->drop_while([](char c) { return c == '/'; }));
106+
commentLines.push_back(line->ltrim('/'));
107107
}
108108

109109
if (commentLines.empty())

0 commit comments

Comments
 (0)