Measure SmallVecs in SelectorMap and InvalidationMap.

This commit is contained in:
Nicholas Nethercote 2017-09-06 15:39:20 +10:00
parent 1cf87a243a
commit ae1216a717
4 changed files with 55 additions and 18 deletions

View file

@ -15,7 +15,7 @@ use selectors::parser::{Selector, SelectorIter, SelectorMethods};
use selectors::visitor::SelectorVisitor;
use smallvec::SmallVec;
#[cfg(feature = "gecko")]
use stylesheets::{MallocEnclosingSizeOfFn, MallocSizeOfHash};
use stylesheets::{MallocEnclosingSizeOfFn, MallocSizeOfFn, MallocSizeOfHash, MallocSizeOfVec};
#[cfg(feature = "gecko")]
/// Gets the element state relevant to the given `:dir` pseudo-class selector.
@ -292,19 +292,29 @@ impl InvalidationMap {
/// Measures heap usage.
#[cfg(feature = "gecko")]
pub fn malloc_size_of_children(&self, malloc_enclosing_size_of: MallocEnclosingSizeOfFn)
pub fn malloc_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
malloc_enclosing_size_of: MallocEnclosingSizeOfFn)
-> usize {
// Currently we measure the HashMap storage, but not things pointed to
// by keys and values.
let mut n = 0;
n += self.class_to_selector.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
n += self.id_to_selector.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
for (_, val) in self.class_to_selector.iter() {
n += val.malloc_shallow_size_of_vec(malloc_size_of);
}
n += self.state_affecting_selectors.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_shallow_size_of_vec(malloc_size_of);
}
n += self.state_affecting_selectors.malloc_size_of_children(malloc_size_of,
malloc_enclosing_size_of);
n += self.other_attribute_affecting_selectors.malloc_size_of_children(
malloc_enclosing_size_of);
malloc_size_of, malloc_enclosing_size_of);
n
}
}