From 7e143372bda676e4f4046e8ef0a16244d75393ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 8 Oct 2017 20:55:10 +0200 Subject: [PATCH] style: Don't go through remove_cycles if there are no references in the specified values. --- components/style/custom_properties.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 692db8cfb09..650dca1829f 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -466,6 +466,7 @@ fn parse_var_function<'i, 't>( /// properties. pub struct CustomPropertiesBuilder<'a> { seen: PrecomputedHashSet<&'a Name>, + may_have_cycles: bool, specified_custom_properties: OrderedMap<&'a Name, Option>>, inherited: Option<&'a Arc>, } @@ -475,6 +476,7 @@ impl<'a> CustomPropertiesBuilder<'a> { pub fn new(inherited: Option<&'a Arc>) -> Self { Self { seen: PrecomputedHashSet::default(), + may_have_cycles: false, specified_custom_properties: OrderedMap::new(), inherited, } @@ -493,6 +495,7 @@ impl<'a> CustomPropertiesBuilder<'a> { match specified_value { DeclaredValue::Value(ref specified_value) => { + self.may_have_cycles |= !specified_value.references.is_empty(); self.specified_custom_properties.insert(name, Some(BorrowedSpecifiedValue { css: &specified_value.css, first_token_type: specified_value.first_token_type, @@ -522,7 +525,9 @@ impl<'a> CustomPropertiesBuilder<'a> { return self.inherited.cloned(); } - remove_cycles(&mut self.specified_custom_properties); + if self.may_have_cycles { + remove_cycles(&mut self.specified_custom_properties); + } Some(Arc::new(substitute_all(self.specified_custom_properties, self.inherited))) } }