replace vector iteration by ascii_case_insensitive_phf_map

This commit is contained in:
Pavel Sergeev 2017-07-17 12:54:49 +03:00 committed by Pavel Sergeev
parent 17f99e2a7b
commit 6a2f84eca4

View file

@ -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