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 {
|
impl SystemColor {
|
||||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||||
#[cfg(feature = "gecko")]
|
ascii_case_insensitive_phf_map! {
|
||||||
use std::ascii::AsciiExt;
|
color_name -> SystemColor = {
|
||||||
static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[
|
% for color in system_colors:
|
||||||
% for color in system_colors:
|
"${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)},
|
||||||
("${color}", LookAndFeel_ColorID::eColorID_${to_rust_ident(color)}),
|
% endfor
|
||||||
% endfor
|
|
||||||
];
|
|
||||||
|
|
||||||
let ident = input.expect_ident()?;
|
|
||||||
for &(name, color) in PARSE_ARRAY.iter() {
|
|
||||||
if name.eq_ignore_ascii_case(&ident) {
|
|
||||||
return Ok(color)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
% endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue