1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +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:
kleines Filmröllchen 2023-10-10 12:42:20 +02:00 committed by Andrew Kaster
parent 7c88ab2836
commit eada4f2ee8
16 changed files with 89 additions and 86 deletions

View file

@ -231,7 +231,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
consume_whitespace();
parse_includes();
consume_whitespace();
lexer.consume_specific("endpoint");
lexer.consume_specific("endpoint"sv);
consume_whitespace();
endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); });
endpoints.last().magic = Traits<ByteString>::hash(endpoints.last().name);