style: Don't waste a whole selector map for each class / id in the document.

It's just useless.
This commit is contained in:
Emilio Cobos Álvarez 2017-09-05 11:52:49 +02:00
parent d880efcab3
commit cc31397a2e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 17 additions and 18 deletions

View file

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