mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Don't go through remove_cycles if there are no references in the specified values.
This commit is contained in:
parent
c354f224ff
commit
7e143372bd
1 changed files with 6 additions and 1 deletions
|
@ -466,6 +466,7 @@ fn parse_var_function<'i, 't>(
|
||||||
/// properties.
|
/// properties.
|
||||||
pub struct CustomPropertiesBuilder<'a> {
|
pub struct CustomPropertiesBuilder<'a> {
|
||||||
seen: PrecomputedHashSet<&'a Name>,
|
seen: PrecomputedHashSet<&'a Name>,
|
||||||
|
may_have_cycles: bool,
|
||||||
specified_custom_properties: OrderedMap<&'a Name, Option<BorrowedSpecifiedValue<'a>>>,
|
specified_custom_properties: OrderedMap<&'a Name, Option<BorrowedSpecifiedValue<'a>>>,
|
||||||
inherited: Option<&'a Arc<CustomPropertiesMap>>,
|
inherited: Option<&'a Arc<CustomPropertiesMap>>,
|
||||||
}
|
}
|
||||||
|
@ -475,6 +476,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||||
pub fn new(inherited: Option<&'a Arc<CustomPropertiesMap>>) -> Self {
|
pub fn new(inherited: Option<&'a Arc<CustomPropertiesMap>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
seen: PrecomputedHashSet::default(),
|
seen: PrecomputedHashSet::default(),
|
||||||
|
may_have_cycles: false,
|
||||||
specified_custom_properties: OrderedMap::new(),
|
specified_custom_properties: OrderedMap::new(),
|
||||||
inherited,
|
inherited,
|
||||||
}
|
}
|
||||||
|
@ -493,6 +495,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||||
|
|
||||||
match specified_value {
|
match specified_value {
|
||||||
DeclaredValue::Value(ref specified_value) => {
|
DeclaredValue::Value(ref specified_value) => {
|
||||||
|
self.may_have_cycles |= !specified_value.references.is_empty();
|
||||||
self.specified_custom_properties.insert(name, Some(BorrowedSpecifiedValue {
|
self.specified_custom_properties.insert(name, Some(BorrowedSpecifiedValue {
|
||||||
css: &specified_value.css,
|
css: &specified_value.css,
|
||||||
first_token_type: specified_value.first_token_type,
|
first_token_type: specified_value.first_token_type,
|
||||||
|
@ -522,7 +525,9 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||||
return self.inherited.cloned();
|
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)))
|
Some(Arc::new(substitute_all(self.specified_custom_properties, self.inherited)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue