Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work with hashbrown 0.11.2 #18

Merged
merged 1 commit into from
May 4, 2021
Merged
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ categories = ["data-structures", "no-std"]

[dependencies]
# For the default hasher
ahash_ = { version = "0.6.1", default-features = false, optional = true, package = "ahash" }
ahash_ = { version = "0.7.0", default-features = false, optional = true, package = "ahash" }

hashbrown = { version = "0.9.1", default-features = false, features = ["raw"] }
hashbrown = { version = "0.11.2", default-features = false, features = ["raw"] }

# For external trait impls
rayon_ = { version = "1.0", optional = true, package = "rayon" }
Expand Down
42 changes: 9 additions & 33 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,10 @@ where
Q: Hash + ?Sized,
S: BuildHasher,
{
#[cfg(feature = "ahash")]
{
//This enables specialization to improve performance on primitive types
use ahash_::CallHasher;
let state = hash_builder.build_hasher();
Q::get_hash(val, state)
}
#[cfg(not(feature = "ahash"))]
{
use core::hash::Hasher;
let mut state = hash_builder.build_hasher();
val.hash(&mut state);
state.finish()
}
use core::hash::Hasher;
let mut state = hash_builder.build_hasher();
val.hash(&mut state);
state.finish()
}

#[cfg_attr(feature = "inline-more", inline)]
Expand All @@ -276,20 +266,10 @@ where
K: Hash,
S: BuildHasher,
{
#[cfg(feature = "ahash")]
{
//This enables specialization to improve performance on primitive types
use ahash_::CallHasher;
let state = hash_builder.build_hasher();
K::get_hash(val, state)
}
#[cfg(not(feature = "ahash"))]
{
use core::hash::Hasher;
let mut state = hash_builder.build_hasher();
val.hash(&mut state);
state.finish()
}
use core::hash::Hasher;
let mut state = hash_builder.build_hasher();
val.hash(&mut state);
state.finish()
}

#[cfg(feature = "ahash")]
Expand Down Expand Up @@ -4385,11 +4365,7 @@ mod test_map {
let mut map: HashMap<_, _> = xs.iter().cloned().collect();

let compute_hash = |map: &HashMap<i32, i32>, k: i32| -> u64 {
use core::hash::{BuildHasher, Hash, Hasher};

let mut hasher = map.hasher().build_hasher();
k.hash(&mut hasher);
hasher.finish()
super::make_insert_hash::<i32, _>(map.hasher(), &k)
};

// Existing key (insert)
Expand Down
2 changes: 1 addition & 1 deletion src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl<T> RawTable<T> {
#[cold]
#[inline(never)]
fn grow(&mut self, extra: usize) {
if let Err(_) = self.try_grow(extra, false) {
if self.try_grow(extra, false).is_err() {
unsafe { core::hint::unreachable_unchecked() };
}
}
Expand Down