Skip to content
Permalink
Browse files

Remove some `use` statements in malloc_size_of.

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 009150696fe354061efe3b826f2aa94456b762fb
Showing with 7 additions and 9 deletions.
  1. +7 −9 components/malloc_size_of/lib.rs
@@ -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;
@@ -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()) }
@@ -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 {
@@ -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
@@ -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

0 comments on commit 0091506

Please sign in to comment.
You can’t perform that action at this time.