mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
AK: Remove ByteString from GenericLexer
A bunch of users used consume_specific with a constant ByteString literal, which can be replaced by an allocation-free StringView literal. The generic consume_while overload gains a requires clause so that consume_specific("abc") causes a more understandable and actionable error.
This commit is contained in:
parent
7c88ab2836
commit
eada4f2ee8
16 changed files with 89 additions and 86 deletions
|
@ -26,7 +26,7 @@ Optional<HunkLocation> Parser::consume_unified_location()
|
|||
return true;
|
||||
};
|
||||
|
||||
if (!consume_specific("@@ -"))
|
||||
if (!consume_specific("@@ -"sv))
|
||||
return {};
|
||||
|
||||
HunkLocation location;
|
||||
|
@ -34,13 +34,13 @@ Optional<HunkLocation> Parser::consume_unified_location()
|
|||
if (!consume_range(location.old_range))
|
||||
return {};
|
||||
|
||||
if (!consume_specific(" +"))
|
||||
if (!consume_specific(" +"sv))
|
||||
return {};
|
||||
|
||||
if (!consume_range(location.new_range))
|
||||
return {};
|
||||
|
||||
if (!consume_specific(" @@"))
|
||||
if (!consume_specific(" @@"sv))
|
||||
return {};
|
||||
|
||||
return location;
|
||||
|
@ -101,12 +101,12 @@ ErrorOr<Header> Parser::parse_header(Optional<size_t> const& strip_count)
|
|||
|
||||
while (!is_eof()) {
|
||||
|
||||
if (consume_specific("+++ ")) {
|
||||
if (consume_specific("+++ "sv)) {
|
||||
header.new_file_path = TRY(parse_file_line(strip_count));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (consume_specific("--- ")) {
|
||||
if (consume_specific("--- "sv)) {
|
||||
header.old_file_path = TRY(parse_file_line(strip_count));
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue