From 0b28bb4c353d4eedccc379f28ea0c28c646378d6 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sat, 27 Jun 2020 07:24:53 -0400 Subject: [PATCH] optimize common case of single style --- src/parse/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index a8eb000..6964597 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -237,12 +237,15 @@ impl<'a> Parser<'a> { '!' | '{' => return Err(("expected \"}\".", *pos).into()), _ => match self.is_selector_or_style()? { SelectorOrStyle::Style(property, value) => { - let styles = if let Some(value) = value { - vec![Style { property, value }] + if let Some(value) = value { + stmts.push(Stmt::Style(Style { property, value })); } else { - self.parse_style_group(property)? - }; - stmts.extend(styles.into_iter().map(Stmt::Style)); + stmts.extend( + self.parse_style_group(property)? + .into_iter() + .map(Stmt::Style), + ); + } } SelectorOrStyle::Selector(init) => { let at_root = self.at_root;