mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 03:09:08 +00:00
LibWeb: Return FlyString from CSS::Parser::Token::ident
Instead of a StringView. This allows us to preserve the nice O(1) string compare property of FlyString, and not needing to allocate when one is needed. Ideally all other places in Token should have similar changes done, but to prevent a huge amount of churn, just change ident for now.
This commit is contained in:
committed by
Andreas Kling
parent
8c8ea86729
commit
3f13a50a20
@@ -729,10 +729,10 @@ Optional<Selector::SimpleSelector::ANPlusBPattern> Parser::parse_a_n_plus_b_patt
|
||||
if (!value.is(Token::Type::Ident))
|
||||
return false;
|
||||
auto ident = value.token().ident();
|
||||
if (!ident.starts_with("n-"sv, CaseSensitivity::CaseInsensitive))
|
||||
if (!ident.starts_with_bytes("n-"sv, CaseSensitivity::CaseInsensitive))
|
||||
return false;
|
||||
for (size_t i = 2; i < ident.length(); ++i) {
|
||||
if (!is_ascii_digit(ident[i]))
|
||||
for (size_t i = 2; i < ident.bytes_as_string_view().length(); ++i) {
|
||||
if (!is_ascii_digit(ident.bytes_as_string_view()[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -741,12 +741,12 @@ Optional<Selector::SimpleSelector::ANPlusBPattern> Parser::parse_a_n_plus_b_patt
|
||||
if (!value.is(Token::Type::Ident))
|
||||
return false;
|
||||
auto ident = value.token().ident();
|
||||
if (!ident.starts_with("-n-"sv, CaseSensitivity::CaseInsensitive))
|
||||
if (!ident.starts_with_bytes("-n-"sv, CaseSensitivity::CaseInsensitive))
|
||||
return false;
|
||||
if (ident.length() == 3)
|
||||
if (ident.bytes_as_string_view().length() == 3)
|
||||
return false;
|
||||
for (size_t i = 3; i < ident.length(); ++i) {
|
||||
if (!is_ascii_digit(ident[i]))
|
||||
for (size_t i = 3; i < ident.bytes_as_string_view().length(); ++i) {
|
||||
if (!is_ascii_digit(ident.bytes_as_string_view()[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -844,7 +844,7 @@ Optional<Selector::SimpleSelector::ANPlusBPattern> Parser::parse_a_n_plus_b_patt
|
||||
}
|
||||
// <dashndashdigit-ident>
|
||||
if (is_dashndashdigit_ident(first_value)) {
|
||||
auto maybe_b = first_value.token().ident().substring_view(2).to_int();
|
||||
auto maybe_b = first_value.token().ident().bytes_as_string_view().substring_view(2).to_int();
|
||||
if (maybe_b.has_value()) {
|
||||
transaction.commit();
|
||||
return Selector::SimpleSelector::ANPlusBPattern { -1, maybe_b.value() };
|
||||
@@ -957,7 +957,7 @@ Optional<Selector::SimpleSelector::ANPlusBPattern> Parser::parse_a_n_plus_b_patt
|
||||
|
||||
// '+'?† <ndashdigit-ident>
|
||||
if (is_ndashdigit_ident(first_after_plus)) {
|
||||
auto maybe_b = first_after_plus.token().ident().substring_view(1).to_int();
|
||||
auto maybe_b = first_after_plus.token().ident().bytes_as_string_view().substring_view(1).to_int();
|
||||
if (maybe_b.has_value()) {
|
||||
transaction.commit();
|
||||
return Selector::SimpleSelector::ANPlusBPattern { 1, maybe_b.value() };
|
||||
|
||||
Reference in New Issue
Block a user