From f02a65b840c3f91a2441aa46bd8a3166f0bcebb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 26 Mar 2017 17:21:49 -0700 Subject: [PATCH] servo: Merge #16141 - style: Add ::from_ident helper to avoid tokenizing the same value multiple times (from emilio:keyword-from-ident); r=nox We can use this to avoid tokenizing multiple times in some places, like #16127. Source-Repo: https://github.com/servo/servo Source-Revision: 447742b0a70395e55d6d1518fa51ad5b190abc8c --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 25adf3ad8feae17a3038424f4c9274d44c54fc58 --- servo/components/style_traits/values.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/servo/components/style_traits/values.rs b/servo/components/style_traits/values.rs index c06652d06db7..a142f3bab489 100644 --- a/servo/components/style_traits/values.rs +++ b/servo/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(()) }