optimize common case of single style

This commit is contained in:
Connor Skees 2020-06-27 07:24:53 -04:00
parent f582439744
commit 0b28bb4c35

View File

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