From a5436e9091e4eb4e781db1f6442f313966a87183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 26 Mar 2017 18:11:02 +0200 Subject: [PATCH] style: Add ::from_ident helper to avoid tokenizing the same value multiple times. --- components/style_traits/values.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/style_traits/values.rs b/components/style_traits/values.rs index c06652d06db..a142f3bab48 100644 --- a/components/style_traits/values.rs +++ b/components/style_traits/values.rs @@ -117,7 +117,12 @@ macro_rules! __define_css_keyword_enum__actual { /// Parse this property from a CSS input stream. pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> { let ident = input.expect_ident()?; - match_ignore_ascii_case! { &ident, + Self::from_ident(&ident) + } + + /// Parse this property from an already-tokenized identifier. + pub fn from_ident(ident: &str) -> Result<$name, ()> { + match_ignore_ascii_case! { ident, $( $css => Ok($name::$variant), )+ _ => Err(()) }