Skip to content

Commit

Permalink
Remove some use statements in malloc_size_of.
Browse files Browse the repository at this point in the history
This file potentially uses multiple implementations of types like `Arc`,
so explicit qualification makes things clearer.
  • Loading branch information
nnethercote committed Sep 26, 2017
1 parent e030c0d commit 0091506
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions components/malloc_size_of/lib.rs
Expand Up @@ -64,8 +64,6 @@ extern crate servo_arc;
extern crate smallbitvec;
extern crate smallvec;

use servo_arc::Arc;
use smallvec::{Array, SmallVec};
use std::hash::{BuildHasher, Hash};
use std::ops::Range;
use std::os::raw::c_void;
Expand Down Expand Up @@ -244,7 +242,7 @@ impl<T: MallocSizeOf> MallocSizeOf for Vec<T> {
}
}

impl<A: Array> MallocShallowSizeOf for SmallVec<A> {
impl<A: smallvec::Array> MallocShallowSizeOf for smallvec::SmallVec<A> {
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if self.spilled() {
unsafe { ops.malloc_size_of(self.as_ptr()) }
Expand All @@ -254,8 +252,8 @@ impl<A: Array> MallocShallowSizeOf for SmallVec<A> {
}
}

impl<A> MallocSizeOf for SmallVec<A>
where A: Array,
impl<A> MallocSizeOf for smallvec::SmallVec<A>
where A: smallvec::Array,
A::Item: MallocSizeOf
{
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
Expand Down Expand Up @@ -348,19 +346,19 @@ impl<K, V, S> MallocSizeOf for hashglobe::hash_map::HashMap<K, V, S>
//impl<T> !MallocSizeOf for Arc<T> { }
//impl<T> !MallocShallowSizeOf for Arc<T> { }

impl<T> MallocUnconditionalShallowSizeOf for Arc<T> {
impl<T> MallocUnconditionalShallowSizeOf for servo_arc::Arc<T> {
fn unconditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
unsafe { ops.malloc_size_of(self.heap_ptr()) }
}
}

impl<T: MallocSizeOf> MallocUnconditionalSizeOf for Arc<T> {
impl<T: MallocSizeOf> MallocUnconditionalSizeOf for servo_arc::Arc<T> {
fn unconditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.unconditional_shallow_size_of(ops) + (**self).size_of(ops)
}
}

impl<T> MallocConditionalShallowSizeOf for Arc<T> {
impl<T> MallocConditionalShallowSizeOf for servo_arc::Arc<T> {
fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if ops.have_seen_ptr(self.heap_ptr()) {
0
Expand All @@ -370,7 +368,7 @@ impl<T> MallocConditionalShallowSizeOf for Arc<T> {
}
}

impl<T: MallocSizeOf> MallocConditionalSizeOf for Arc<T> {
impl<T: MallocSizeOf> MallocConditionalSizeOf for servo_arc::Arc<T> {
fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if ops.have_seen_ptr(self.heap_ptr()) {
0
Expand Down

0 comments on commit 0091506

Please sign in to comment.