From eeed0b17eb21a5825ae4d454ee14fc824ce11eb4 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 Sep 2017 09:06:20 +1000 Subject: [PATCH] Fix MallocSizeOf for TypedSize2D. TypedSize2D's MallocSizeOf impl has two problems. - It measures `width` twice, and `height` not at all. - It erroneously asserts that `width` and `height` are scalars. This seems reasonable at first blush, but Stylo uses `BorderRadius` which contains a `TypedSize2D`, and `LengthAndPercentage` is non-scalar. This patch fixes both of these problems, and also removes a low-value `use` statement. --- components/malloc_size_of/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 648273394595..0e802d386103 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -64,7 +64,6 @@ extern crate servo_arc; extern crate smallbitvec; extern crate smallvec; -use euclid::TypedSize2D; use servo_arc::Arc; use smallvec::{Array, SmallVec}; use std::hash::{BuildHasher, Hash}; @@ -391,11 +390,9 @@ impl MallocSizeOf for smallbitvec::SmallBitVec { } } -impl MallocSizeOf for TypedSize2D { +impl MallocSizeOf for euclid::TypedSize2D { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - let n = self.width.size_of(ops) + self.width.size_of(ops); - assert!(n == 0); // It would be very strange to have a non-zero value here... - n + self.width.size_of(ops) + self.height.size_of(ops) } }