Skip to content

Commit

Permalink
Auto merge of #196 - nnethercote:rm-heapsize, r=jdm
Browse files Browse the repository at this point in the history
Remove `heapsize` dependency.

The heapsize crate is being deprecated in favour of the malloc_size_of
crate within Servo.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/string-cache/196)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Oct 24, 2017
2 parents 4a027b0 + f48bdff commit 4f8310c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ script:
- cargo test
- cargo test --features log-events
- "if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo test --features unstable; fi"
- cargo test --features heapsize
- cargo test
- "cd string-cache-codegen/ && cargo build && cd .."
- "cd examples/event-log/ && cargo build && cd ../.."
- "cd examples/summarize-events/ && cargo build && cd ../.."
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "string_cache"
version = "0.6.3" # Also update README.md when making a semver-breaking change
version = "0.7.0" # Also update README.md when making a semver-breaking change
authors = [ "The Servo Project Developers" ]
description = "A string interning library for Rust, developed as part of the Servo project."
license = "MIT / Apache-2.0"
Expand Down Expand Up @@ -33,7 +33,6 @@ lazy_static = "0.2"
serde = "1"
phf_shared = "0.7.4"
debug_unreachable = "0.1.1"
heapsize = { version = ">= 0.3, < 0.5", optional = true }
string_cache_shared = {path = "./shared", version = "0.3"}

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In `Cargo.toml`:

```toml
[dependencies]
string_cache = "0.6"
string_cache = "0.7"
```

In `lib.rs`:
Expand All @@ -31,7 +31,7 @@ In `Cargo.toml`:
build = "build.rs"

[dependencies]
string_cache = "0.5"
string_cache = "0.7"

[build-dependencies]
string_cache_codegen = "0.4"
Expand Down
37 changes: 0 additions & 37 deletions src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

#![allow(non_upper_case_globals)]

#[cfg(feature = "heapsize")]
use heapsize::HeapSizeOf;

use phf_shared;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

Expand Down Expand Up @@ -46,43 +43,17 @@ struct StringCache {
buckets: [Option<Box<StringCacheEntry>>; NB_BUCKETS],
}

#[cfg(feature = "heapsize")]
impl HeapSizeOf for StringCache {
fn heap_size_of_children(&self) -> usize {
self.buckets.iter().fold(0, |size, bucket| size + bucket.heap_size_of_children())
}
}

lazy_static! {
static ref STRING_CACHE: Mutex<StringCache> = Mutex::new(StringCache::new());
}

/// A token that represents the heap used by the dynamic string cache.
#[cfg(feature = "heapsize")]
pub struct StringCacheHeap;

#[cfg(feature = "heapsize")]
impl HeapSizeOf for StringCacheHeap {
fn heap_size_of_children(&self) -> usize {
STRING_CACHE.lock().unwrap().heap_size_of_children()
}
}

struct StringCacheEntry {
next_in_bucket: Option<Box<StringCacheEntry>>,
hash: u64,
ref_count: AtomicIsize,
string: Box<str>,
}

#[cfg(feature = "heapsize")]
impl HeapSizeOf for StringCacheEntry {
fn heap_size_of_children(&self) -> usize {
self.next_in_bucket.heap_size_of_children() +
self.string.heap_size_of_children()
}
}

impl StringCacheEntry {
fn new(next: Option<Box<StringCacheEntry>>, hash: u64, string: String)
-> StringCacheEntry {
Expand Down Expand Up @@ -213,14 +184,6 @@ pub struct Atom<Static: StaticAtomSet> {
pub phantom: PhantomData<Static>,
}

#[cfg(feature = "heapsize")]
impl<Static: StaticAtomSet> HeapSizeOf for Atom<Static> {
#[inline(always)]
fn heap_size_of_children(&self) -> usize {
0
}
}

impl<Static: StaticAtomSet> ::precomputed_hash::PrecomputedHash for Atom<Static> {
fn precomputed_hash(&self) -> u32 {
self.get_hash()
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#![cfg_attr(all(test, feature = "unstable"), feature(test))]

#[cfg(all(test, feature = "unstable"))] extern crate test;
#[cfg(feature = "heapsize")] extern crate heapsize;
#[cfg(all(test, feature = "unstable"))] extern crate rand;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate debug_unreachable;
Expand Down

0 comments on commit 4f8310c

Please sign in to comment.