mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Don't waste a whole selector map for each class / id in the document.
It's just useless.
This commit is contained in:
parent
d880efcab3
commit
cc31397a2e
2 changed files with 17 additions and 18 deletions
|
@ -139,10 +139,10 @@ impl SelectorMapEntry for StateDependency {
|
|||
pub struct InvalidationMap {
|
||||
/// A map from a given class name to all the selectors with that class
|
||||
/// selector.
|
||||
pub class_to_selector: MaybeCaseInsensitiveHashMap<Atom, SelectorMap<Dependency>>,
|
||||
pub class_to_selector: MaybeCaseInsensitiveHashMap<Atom, SmallVec<[Dependency; 1]>>,
|
||||
/// A map from a given id to all the selectors with that ID in the
|
||||
/// stylesheets currently applying to the document.
|
||||
pub id_to_selector: MaybeCaseInsensitiveHashMap<Atom, SelectorMap<Dependency>>,
|
||||
pub id_to_selector: MaybeCaseInsensitiveHashMap<Atom, SmallVec<[Dependency; 1]>>,
|
||||
/// A map of all the state dependencies.
|
||||
pub state_affecting_selectors: SelectorMap<StateDependency>,
|
||||
/// A map of other attribute affecting selectors.
|
||||
|
@ -245,21 +245,21 @@ impl InvalidationMap {
|
|||
for class in compound_visitor.classes {
|
||||
self.class_to_selector
|
||||
.entry(class, quirks_mode)
|
||||
.or_insert_with(SelectorMap::new)
|
||||
.insert(Dependency {
|
||||
.or_insert_with(SmallVec::new)
|
||||
.push(Dependency {
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
}, quirks_mode);
|
||||
})
|
||||
}
|
||||
|
||||
for id in compound_visitor.ids {
|
||||
self.id_to_selector
|
||||
.entry(id, quirks_mode)
|
||||
.or_insert_with(SelectorMap::new)
|
||||
.insert(Dependency {
|
||||
.or_insert_with(SmallVec::new)
|
||||
.push(Dependency {
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
}, quirks_mode);
|
||||
})
|
||||
}
|
||||
|
||||
if !compound_visitor.state.is_empty() {
|
||||
|
@ -299,14 +299,7 @@ impl InvalidationMap {
|
|||
let mut n = 0;
|
||||
|
||||
n += self.class_to_selector.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
|
||||
for (_, val) in self.class_to_selector.iter() {
|
||||
n += val.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
}
|
||||
|
||||
n += self.id_to_selector.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
|
||||
for (_, val) in self.id_to_selector.iter() {
|
||||
n += val.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
}
|
||||
|
||||
n += self.state_affecting_selectors.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
|
||||
|
|
|
@ -792,20 +792,26 @@ impl<'a, 'b: 'a, E> InvalidationCollector<'a, 'b, E>
|
|||
let removed_id = self.removed_id;
|
||||
if let Some(ref id) = removed_id {
|
||||
if let Some(deps) = map.id_to_selector.get(id, quirks_mode) {
|
||||
self.collect_dependencies_in_map(deps)
|
||||
for dep in deps {
|
||||
self.scan_dependency(dep, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let added_id = self.added_id;
|
||||
if let Some(ref id) = added_id {
|
||||
if let Some(deps) = map.id_to_selector.get(id, quirks_mode) {
|
||||
self.collect_dependencies_in_map(deps)
|
||||
for dep in deps {
|
||||
self.scan_dependency(dep, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for class in self.classes_added.iter().chain(self.classes_removed.iter()) {
|
||||
if let Some(deps) = map.class_to_selector.get(class, quirks_mode) {
|
||||
self.collect_dependencies_in_map(deps)
|
||||
for dep in deps {
|
||||
self.scan_dependency(dep, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue