Skip to content

Commit ba9bde9

Browse files
committed
Remove use of heapsize_plugin
1 parent 31dea0b commit ba9bde9

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ script:
1212
- cargo test
1313
- cargo test --features log-events
1414
- "if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo test --features unstable; fi"
15-
- "if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo test --features heap_size; fi"
15+
- cargo test --features heapsize
1616
- "cd examples/event-log/ && cargo build && cd ../.."
1717
- "cd examples/summarize-events/ && cargo build && cd ../.."
1818
notifications:

Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ log-events = ["rustc-serialize"]
2525
unstable = []
2626

2727
# HeapSizeOf support
28-
heap_size = ["heapsize", "heapsize_plugin"]
28+
heap_size = ["heapsize"]
2929

3030
[dependencies]
3131
lazy_static = "0.2"
@@ -44,10 +44,6 @@ optional = true
4444
version = ">=0.1.1, <0.4"
4545
optional = true
4646

47-
[dependencies.heapsize_plugin]
48-
version = "0.1.4"
49-
optional = true
50-
5147
[build-dependencies]
5248
phf_generator = "0.7.4"
5349
phf_shared = "0.7.4"

src/atom/mod.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#![allow(non_upper_case_globals)]
1111

12-
#[cfg(feature = "heap_size")]
12+
#[cfg(feature = "heapsize")]
1313
use heapsize::HeapSizeOf;
1414

1515
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -46,7 +46,7 @@ struct StringCache {
4646
buckets: [Option<Box<StringCacheEntry>>; NB_BUCKETS],
4747
}
4848

49-
#[cfg(feature = "heap_size")]
49+
#[cfg(feature = "heapsize")]
5050
impl HeapSizeOf for StringCache {
5151
fn heap_size_of_children(&self) -> usize {
5252
self.buckets.iter().fold(0, |size, bucket| size + bucket.heap_size_of_children())
@@ -58,24 +58,31 @@ lazy_static! {
5858
}
5959

6060
/// A token that represents the heap used by the dynamic string cache.
61-
#[cfg(feature = "heap_size")]
61+
#[cfg(feature = "heapsize")]
6262
pub struct StringCacheHeap;
6363

64-
#[cfg(feature = "heap_size")]
64+
#[cfg(feature = "heapsize")]
6565
impl HeapSizeOf for StringCacheHeap {
6666
fn heap_size_of_children(&self) -> usize {
6767
STRING_CACHE.lock().unwrap().heap_size_of_children()
6868
}
6969
}
7070

71-
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
7271
struct StringCacheEntry {
7372
next_in_bucket: Option<Box<StringCacheEntry>>,
7473
hash: u64,
7574
ref_count: AtomicIsize,
7675
string: Box<str>,
7776
}
7877

78+
#[cfg(feature = "heapsize")]
79+
impl HeapSizeOf for StringCacheEntry {
80+
fn heap_size_of_children(&self) -> usize {
81+
self.next_in_bucket.heap_size_of_children() +
82+
self.string.heap_size_of_children()
83+
}
84+
}
85+
7986
impl StringCacheEntry {
8087
fn new(next: Option<Box<StringCacheEntry>>, hash: u64, string: String)
8188
-> StringCacheEntry {
@@ -163,7 +170,6 @@ impl StringCache {
163170
// NOTE: Deriving Eq here implies that a given string must always
164171
// be interned the same way.
165172
#[cfg_attr(feature = "unstable", unsafe_no_drop_flag)] // See tests::atom_drop_is_idempotent
166-
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
167173
#[derive(Eq, Hash, PartialEq)]
168174
pub struct Atom {
169175
/// This field is public so that the `atom!()` macro can use it.
@@ -172,6 +178,9 @@ pub struct Atom {
172178
pub unsafe_data: u64,
173179
}
174180

181+
#[cfg(feature = "heapsize")]
182+
known_heap_size!(0, Atom);
183+
175184
pub struct BorrowedAtom<'a>(pub &'a Atom);
176185

177186
impl<'a> ops::Deref for BorrowedAtom<'a> {

src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
#![cfg_attr(test, deny(warnings))]
1414
#![cfg_attr(all(test, feature = "unstable"), feature(test, filling_drop))]
1515
#![cfg_attr(feature = "unstable", feature(unsafe_no_drop_flag))]
16-
#![cfg_attr(feature = "heap_size", feature(plugin, custom_derive))]
17-
#![cfg_attr(feature = "heap_size", plugin(heapsize_plugin))]
1816

1917
#[cfg(all(test, feature = "unstable"))] extern crate test;
2018
#[cfg(feature = "log-events")] extern crate rustc_serialize;
21-
#[cfg(feature = "heap_size")] extern crate heapsize;
19+
#[cfg(feature = "heapsize")] #[macro_use] extern crate heapsize;
2220
#[cfg(test)] extern crate rand;
2321
#[macro_use] extern crate lazy_static;
2422
#[macro_use] extern crate debug_unreachable;

src/namespace.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ use std::ops;
1616
/// Whether a given string represents a namespace is contextual, so this is
1717
/// a transparent wrapper that will not catch all mistakes.
1818
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Default)]
19-
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
2019
pub struct Namespace(pub Atom);
2120

21+
#[cfg(feature = "heapsize")]
22+
known_heap_size!(0, Namespace);
23+
2224
pub struct BorrowedNamespace<'a>(pub &'a Namespace);
2325

2426
impl<'a> ops::Deref for BorrowedNamespace<'a> {
@@ -36,12 +38,14 @@ impl<'a> PartialEq<Namespace> for BorrowedNamespace<'a> {
3638

3739
/// A name with a namespace.
3840
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
39-
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
4041
pub struct QualName {
4142
pub ns: Namespace,
4243
pub local: Atom,
4344
}
4445

46+
#[cfg(feature = "heapsize")]
47+
known_heap_size!(0, QualName);
48+
4549
impl QualName {
4650
#[inline]
4751
pub fn new(ns: Namespace, local: Atom) -> QualName {

0 commit comments

Comments
 (0)