mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
replace vector iteration by ascii_case_insensitive_phf_map
This commit is contained in:
parent
17f99e2a7b
commit
6a2f84eca4
1 changed files with 12 additions and 13 deletions
|
@ -121,21 +121,20 @@
|
|||
|
||||
impl SystemColor {
|
||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
#[cfg(feature = "gecko")]
|
||||
use std::ascii::AsciiExt;
|
||||
static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[
|
||||
% for color in system_colors:
|
||||
("${color}", LookAndFeel_ColorID::eColorID_${to_rust_ident(color)}),
|
||||
% endfor
|
||||
];
|
||||
|
||||
let ident = input.expect_ident()?;
|
||||
for &(name, color) in PARSE_ARRAY.iter() {
|
||||
if name.eq_ignore_ascii_case(&ident) {
|
||||
return Ok(color)
|
||||
ascii_case_insensitive_phf_map! {
|
||||
color_name -> SystemColor = {
|
||||
% for color in system_colors:
|
||||
"${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
Err(SelectorParseError::UnexpectedIdent(ident).into())
|
||||
|
||||
let ident = input.expect_ident()?;
|
||||
if let Some(color) = color_name(&ident) {
|
||||
Ok(*color)
|
||||
} else {
|
||||
Err(SelectorParseError::UnexpectedIdent(ident).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue