Skip to content

Commit

Permalink
Update string-interner and hashbrown dependencies (#1305)
Browse files Browse the repository at this point in the history
* update string-interner to v0.18.0

* update hashbrown to v0.15.1

* use hashbrown's hashing utilities
  • Loading branch information
Robbepop authored Nov 12, 2024
1 parent cba63fe commit 1e68682
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
18 changes: 8 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ categories.workspace = true
exclude.workspace = true

[dependencies]
hashbrown = { version = "0.14", default-features = false, optional = true, features = ["ahash", "inline-more"] }
string-interner = { version = "0.17", default-features = false, optional = true, features = ["inline-more", "backends"] }
ahash = { version = "0.8.11", default-features = false, optional = true }
hashbrown = { version = "0.15.1", default-features = false, optional = true, features = ["default-hasher", "inline-more"] }
string-interner = { version = "0.18", default-features = false, optional = true, features = ["inline-more", "backends"] }

[features]
default = ["std"]
Expand Down Expand Up @@ -46,7 +45,6 @@ std = ["string-interner?/std"]
hash-collections = [
'dep:hashbrown',
'dep:string-interner',
'dep:ahash',
]
prefer-btree-collections = []

Expand Down
10 changes: 5 additions & 5 deletions crates/collections/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,29 @@ impl Hasher for RandomStateHasher {
#[cfg(feature = "std")]
use std::collections::hash_map::RandomState as RandomStateImpl;

// When the `std` feature is NOT active then rely on `ahash::RandomState`
// When the `std` feature is NOT active then rely on `hashbrown`'s `RandomState`
// which relies on ASLR by default for randomness.
#[derive(Clone, Debug)]
#[cfg(not(feature = "std"))]
struct RandomStateImpl {
state: ahash::RandomState,
state: hashbrown::DefaultHashBuilder,
}

#[cfg(not(feature = "std"))]
impl Default for RandomStateImpl {
fn default() -> Self {
Self {
state: ahash::RandomState::new(),
state: hashbrown::DefaultHashBuilder::default(),
}
}
}

#[cfg(not(feature = "std"))]
impl BuildHasher for RandomStateImpl {
type Hasher = ahash::AHasher;
type Hasher = <hashbrown::DefaultHashBuilder as BuildHasher>::Hasher;

#[inline]
fn build_hasher(&self) -> ahash::AHasher {
fn build_hasher(&self) -> Self::Hasher {
self.state.build_hasher()
}
}

0 comments on commit 1e68682

Please sign in to comment.