Implement MallocSizeOf properly for SmallBitVec.

This commit is contained in:
Nicholas Nethercote 2017-09-18 13:19:31 +10:00
parent 280ccf685d
commit 9d057724eb

View file

@ -384,6 +384,16 @@ impl<T: MallocSizeOf> MallocConditionalSizeOf for Arc<T> {
} }
} }
impl MallocSizeOf for smallbitvec::SmallBitVec {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if let Some(ptr) = self.heap_ptr() {
unsafe { ops.malloc_size_of(ptr) }
} else {
0
}
}
}
impl<T: MallocSizeOf, U> MallocSizeOf for TypedSize2D<T, U> { impl<T: MallocSizeOf, U> MallocSizeOf for TypedSize2D<T, U> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
let n = self.width.size_of(ops) + self.width.size_of(ops); let n = self.width.size_of(ops) + self.width.size_of(ops);
@ -428,7 +438,3 @@ size_of_is_0!(Range<f32>, Range<f64>);
size_of_is_0!(app_units::Au); size_of_is_0!(app_units::Au);
size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType); size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
// XXX: once we upgrade smallbitvec to 1.0.4, use the new heap_ptr() method to
// implement this properly
size_of_is_0!(smallbitvec::SmallBitVec);