mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +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
|
@ -33,18 +33,18 @@ public:
|
|||
|
||||
lexer.ignore_while(is_ascii_space);
|
||||
|
||||
if (lexer.consume_specific("inline")) {
|
||||
if (lexer.consume_specific("inline"sv)) {
|
||||
m_kind = Kind::Inline;
|
||||
if (!lexer.is_eof())
|
||||
m_might_be_wrong = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lexer.consume_specific("attachment")) {
|
||||
if (lexer.consume_specific("attachment"sv)) {
|
||||
m_kind = Kind::Attachment;
|
||||
if (lexer.consume_specific(";")) {
|
||||
if (lexer.consume_specific(";"sv)) {
|
||||
lexer.ignore_while(is_ascii_space);
|
||||
if (lexer.consume_specific("filename=")) {
|
||||
if (lexer.consume_specific("filename="sv)) {
|
||||
// RFC 2183: "A short (length <= 78 characters)
|
||||
// parameter value containing only non-`tspecials' characters SHOULD be
|
||||
// represented as a single `token'."
|
||||
|
@ -62,13 +62,13 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
if (lexer.consume_specific("form-data")) {
|
||||
if (lexer.consume_specific("form-data"sv)) {
|
||||
m_kind = Kind::FormData;
|
||||
while (lexer.consume_specific(";")) {
|
||||
while (lexer.consume_specific(";"sv)) {
|
||||
lexer.ignore_while(is_ascii_space);
|
||||
if (lexer.consume_specific("name=")) {
|
||||
if (lexer.consume_specific("name="sv)) {
|
||||
m_name = lexer.consume_quoted_string();
|
||||
} else if (lexer.consume_specific("filename=")) {
|
||||
} else if (lexer.consume_specific("filename="sv)) {
|
||||
if (lexer.next_is('"'))
|
||||
m_filename = lexer.consume_quoted_string();
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue