mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 01:07:44 +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
|
@ -24,12 +24,12 @@ ByteBuffer decode_pem(ReadonlyBytes data)
|
|||
while (!lexer.is_eof()) {
|
||||
switch (state) {
|
||||
case PreStartData:
|
||||
if (lexer.consume_specific("-----BEGIN"))
|
||||
if (lexer.consume_specific("-----BEGIN"sv))
|
||||
state = Started;
|
||||
lexer.consume_line();
|
||||
break;
|
||||
case Started: {
|
||||
if (lexer.consume_specific("-----END")) {
|
||||
if (lexer.consume_specific("-----END"sv)) {
|
||||
state = Ended;
|
||||
lexer.consume_line();
|
||||
break;
|
||||
|
@ -69,12 +69,12 @@ ErrorOr<Vector<ByteBuffer>> decode_pems(ReadonlyBytes data)
|
|||
while (!lexer.is_eof()) {
|
||||
switch (state) {
|
||||
case Junk:
|
||||
if (lexer.consume_specific("-----BEGIN"))
|
||||
if (lexer.consume_specific("-----BEGIN"sv))
|
||||
state = Parsing;
|
||||
lexer.consume_line();
|
||||
break;
|
||||
case Parsing: {
|
||||
if (lexer.consume_specific("-----END")) {
|
||||
if (lexer.consume_specific("-----END"sv)) {
|
||||
state = Junk;
|
||||
lexer.consume_line();
|
||||
TRY(pems.try_append(decoded));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue