From 9d057724ebe79fee05c33e913809dff0791b0dcc Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Sep 2017 13:19:31 +1000 Subject: [PATCH] Implement MallocSizeOf properly for SmallBitVec. --- components/malloc_size_of/lib.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 671e4b9e139..e245895f27c 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -384,6 +384,16 @@ impl MallocConditionalSizeOf for Arc { } } +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 MallocSizeOf for TypedSize2D { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { let n = self.width.size_of(ops) + self.width.size_of(ops); @@ -428,7 +438,3 @@ size_of_is_0!(Range, Range); size_of_is_0!(app_units::Au); 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);