Skip to content

Commit 79766e5

Browse files
committed
Remove heapsize dependency.
The heapsize crate is being deprecated in favour of the malloc_size_of crate within Servo.
1 parent 1318d76 commit 79766e5

File tree

2 files changed

+1
-53
lines changed

2 files changed

+1
-53
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "smallvec"
3-
version = "0.4.4"
3+
version = "0.5.0"
44
authors = ["Simon Sapin <[email protected]>"]
55
license = "MPL-2.0"
66
repository = "https://github.com/servo/rust-smallvec"
@@ -10,7 +10,6 @@ readme = "README.md"
1010
documentation = "http://doc.servo.org/smallvec/"
1111

1212
[features]
13-
heapsizeof = ["heapsize", "std"]
1413
std = []
1514
default = ["std"]
1615

@@ -19,7 +18,6 @@ name = "smallvec"
1918
path = "lib.rs"
2019

2120
[dependencies]
22-
heapsize = { version = "0.4", optional = true }
2321
serde = { version = "1", optional = true }
2422

2523
[dev_dependencies]

lib.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ extern crate alloc;
2626
#[cfg(not(feature = "std"))]
2727
use alloc::Vec;
2828

29-
#[cfg(feature="heapsizeof")]
30-
extern crate heapsize;
31-
3229
#[cfg(feature = "serde")]
3330
extern crate serde;
3431

@@ -48,17 +45,13 @@ use std::ptr;
4845
use std::slice;
4946
#[cfg(feature = "std")]
5047
use std::io;
51-
#[cfg(feature="heapsizeof")]
52-
use std::os::raw::c_void;
5348
#[cfg(feature = "serde")]
5449
use serde::ser::{Serialize, Serializer, SerializeSeq};
5550
#[cfg(feature = "serde")]
5651
use serde::de::{Deserialize, Deserializer, SeqAccess, Visitor};
5752
#[cfg(feature = "serde")]
5853
use std::marker::PhantomData;
5954

60-
#[cfg(feature="heapsizeof")]
61-
use heapsize::{HeapSizeOf, heap_size_of};
6255
use SmallVecData::{Inline, Heap};
6356

6457
/// Common operations implemented by both `Vec` and `SmallVec`.
@@ -688,20 +681,6 @@ impl<A: Array> SmallVec<A> where A::Item: Copy {
688681
}
689682
}
690683

691-
#[cfg(feature="heapsizeof")]
692-
impl<A: Array> HeapSizeOf for SmallVec<A> where A::Item: HeapSizeOf {
693-
fn heap_size_of_children(&self) -> usize {
694-
match self.data {
695-
Inline { .. } => 0,
696-
Heap { ptr, .. } => {
697-
self.iter().fold(
698-
unsafe { heap_size_of(ptr as *const c_void) },
699-
|n, elem| n + elem.heap_size_of_children())
700-
},
701-
}
702-
}
703-
}
704-
705684
impl<A: Array> ops::Deref for SmallVec<A> {
706685
type Target = [A::Item];
707686
#[inline]
@@ -1134,11 +1113,6 @@ pub mod tests {
11341113
#[cfg(not(feature = "std"))]
11351114
use alloc::vec::Vec;
11361115

1137-
#[cfg(feature="heapsizeof")]
1138-
use heapsize::HeapSizeOf;
1139-
#[cfg(feature="heapsizeof")]
1140-
use std::mem::size_of;
1141-
11421116
// We heap allocate all these strings so that double frees will show up under valgrind.
11431117

11441118
#[test]
@@ -1599,30 +1573,6 @@ pub mod tests {
15991573
assert_eq!(&SmallVec::<[u32; 2]>::from_slice(&[1, 2, 3][..])[..], [1, 2, 3]);
16001574
}
16011575

1602-
#[cfg(feature="heapsizeof")]
1603-
#[test]
1604-
fn test_heap_size_of_children() {
1605-
let mut vec = SmallVec::<[u32; 2]>::new();
1606-
assert_eq!(vec.heap_size_of_children(), 0);
1607-
vec.push(1);
1608-
vec.push(2);
1609-
assert_eq!(vec.heap_size_of_children(), 0);
1610-
vec.push(3);
1611-
assert_eq!(vec.heap_size_of_children(), 16);
1612-
1613-
// Now check with reserved space
1614-
let mut vec = SmallVec::<[u32; 2]>::new();
1615-
vec.reserve(10); // Rounds up to 16
1616-
assert_eq!(vec.heap_size_of_children(), 64);
1617-
1618-
// Check with nested heap structures
1619-
let mut vec = SmallVec::<[Vec<u32>; 2]>::new();
1620-
vec.reserve(10);
1621-
vec.push(vec![2, 3, 4]);
1622-
assert_eq!(vec.heap_size_of_children(),
1623-
vec![2, 3, 4].heap_size_of_children() + 16 * size_of::<Vec<u32>>());
1624-
}
1625-
16261576
#[test]
16271577
fn test_exact_size_iterator() {
16281578
let mut vec = SmallVec::<[u32; 2]>::from(&[1, 2, 3][..]);

0 commit comments

Comments
 (0)