Skip to content


Browse files Browse the repository at this point in the history
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<LengthAndPercentage>` which contains a
  `TypedSize2D<LengthAndPercentage, UnknownUnit>`, and
  `LengthAndPercentage` is non-scalar.

This patch fixes both of these problems, and also removes a low-value
`use` statement.
  • Loading branch information
nnethercote committed Sep 20, 2017
1 parent 6a791cd commit eeed0b1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions components/malloc_size_of/
Expand Up @@ -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};
Expand Down Expand Up @@ -391,11 +390,9 @@ impl MallocSizeOf for smallbitvec::SmallBitVec {

impl<T: MallocSizeOf, U> MallocSizeOf for TypedSize2D<T, U> {
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedSize2D<T, U> {
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...
self.width.size_of(ops) + self.height.size_of(ops)

Expand Down

0 comments on commit eeed0b1

Please sign in to comment.