Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benches/creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let s = raft.clone();
c.bench_function("single raft ustr", move |b| {
b.iter(|| {
unsafe { ustr::_clear_cache() };
unsafe { ustr::_clear_cache::<Dataless>() };
for s in s.iter().cycle().take(100_000) {
black_box(ustr(s));
}
Expand Down Expand Up @@ -102,7 +102,7 @@ fn criterion_benchmark(c: &mut Criterion) {
}

b.iter(|| {
unsafe { ustr::_clear_cache() };
unsafe { ustr::_clear_cache::<Dataless>() };
for _ in 0..num_threads {
tx1.send(()).unwrap();
}
Expand Down Expand Up @@ -262,7 +262,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let s = raft_large.clone();
c.bench_function("raft large x1", move |b| {
b.iter(|| {
unsafe { ustr::_clear_cache() };
unsafe { ustr::_clear_cache::<Dataless>() };
for s in s.iter().cycle().take(100_000) {
black_box(ustr(s));
}
Expand Down Expand Up @@ -292,7 +292,7 @@ fn criterion_benchmark(c: &mut Criterion) {
}

b.iter(|| {
unsafe { ustr::_clear_cache() };
unsafe { ustr::_clear_cache::<Dataless>() };
for _ in 0..num_threads {
tx1.send(()).unwrap();
}
Expand Down
11 changes: 8 additions & 3 deletions src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
use super::Ustr;
use crate::{Dataless, InternedString};

use byteorder::{ByteOrder, NativeEndian};
use std::{
collections::{HashMap, HashSet},
hash::{BuildHasherDefault, Hasher},
};

pub type InternedStringMap<V, N> =
HashMap<InternedString<N>, V, BuildHasherDefault<IdentityHasher>>;
/// A standard `HashMap` using `Ustr` as the key type with a custom `Hasher`
/// that just uses the precomputed hash for speed instead of calculating it.
pub type UstrMap<V> = HashMap<Ustr, V, BuildHasherDefault<IdentityHasher>>;
pub type UstrMap<V> = InternedStringMap<V, Dataless>;

/// A standard `HashSet` using `Ustr` as the key type with a custom `Hasher`
/// that just uses the precomputed hash for speed instead of calculating it.
pub type UstrSet = HashSet<Ustr, BuildHasherDefault<IdentityHasher>>;
pub type InternedStringSet<N> =
HashSet<InternedString<N>, BuildHasherDefault<IdentityHasher>>;
pub type UstrSet = InternedStringSet<Dataless>;

/// The worst hasher in the world -- the identity hasher.
#[doc(hidden)]
Expand Down
Loading