perf(css/parser): Use ascii operations (#5808)

**Description:**

We don't need Unicode handling in these cases.
This commit is contained in:
Donny/강동윤 2022-09-10 17:32:35 +09:00 committed by GitHub
parent 417b1f2a92
commit 96cc888ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -23,7 +23,7 @@ where
unreachable!()
}
};
let lowercased_name = &*at_keyword_name.0.to_lowercase();
let lowercased_name = &*at_keyword_name.0.to_ascii_lowercase();
let at_rule_name = if at_keyword_name.0.starts_with("--") {
AtRuleName::DashedIdent(DashedIdent {
span: Span::new(
@ -1072,7 +1072,7 @@ where
Ok(SupportsFeature::Declaration(declaration))
}
Token::Function { value, .. } if &*value.to_lowercase() == "selector" => {
Token::Function { value, .. } if &*value.to_ascii_lowercase() == "selector" => {
// TODO improve me
let ctx = Ctx {
block_contents_grammar: BlockContentsGrammar::DeclarationValue,

View File

@ -326,7 +326,7 @@ where
let mut is_legacy_syntax = true;
match cur!(self) {
Token::Ident { value, .. } if &*value.to_lowercase() == "from" => {
Token::Ident { value, .. } if &*value.to_ascii_lowercase() == "from" => {
is_legacy_syntax = false;
values.push(ComponentValue::Ident(self.parse()?));
@ -664,7 +664,8 @@ where
match cur!(self) {
Token::Ident { value, .. }
if &*value.to_lowercase() == "from" && function_name != "device-cmyk" =>
if &*value.to_ascii_lowercase() == "from"
&& function_name != "device-cmyk" =>
{
values.push(ComponentValue::Ident(self.parse()?));
@ -1011,7 +1012,7 @@ where
self.input.skip_ws()?;
match cur!(self) {
Token::Ident { value, .. } if &*value.to_lowercase() == "from" => {
Token::Ident { value, .. } if &*value.to_ascii_lowercase() == "from" => {
values.push(self.try_parse_variable_function(|parser| {
Ok(ComponentValue::Ident(parser.parse()?))
})?);