Skip to content

Commit

Permalink
chore: update hashbrown to 0.15 (#9974)
Browse files Browse the repository at this point in the history
* chore: update `hashbrown` to 0.15

* fmt
  • Loading branch information
JonasKruckenberg authored Jan 10, 2025
1 parent de1ad34 commit f2fb00d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ env_logger = "0.11.5"
log = { version = "0.4.8", default-features = false }
clap = { version = "4.5.17", default-features = false, features = ["std", "derive"] }
clap_complete = "4.4.7"
hashbrown = { version = "0.14", default-features = false }
hashbrown = { version = "0.15", default-features = false }
capstone = "0.12.0"
smallvec = { version = "1.6.1", features = ["union"] }
tracing = "0.1.26"
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cranelift-entity = { workspace = true }
cranelift-bforest = { workspace = true }
cranelift-bitset = { workspace = true }
cranelift-control = { workspace = true }
hashbrown = { workspace = true, features = ["raw"] }
hashbrown = { workspace = true }
target-lexicon = { workspace = true }
log = { workspace = true }
serde = { workspace = true, optional = true }
Expand Down
20 changes: 7 additions & 13 deletions cranelift/codegen/src/ctxhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! node-internal data references some other storage (e.g., offsets into
//! an array or pool of shared data).
use hashbrown::raw::RawTable;
use hashbrown::hash_table::HashTable;
use std::hash::{Hash, Hasher};

/// Trait that allows for equality comparison given some external
Expand Down Expand Up @@ -59,15 +59,15 @@ struct BucketData<K, V> {

/// A HashMap that takes external context for all operations.
pub struct CtxHashMap<K, V> {
raw: RawTable<BucketData<K, V>>,
raw: HashTable<BucketData<K, V>>,
}

impl<K, V> CtxHashMap<K, V> {
/// Create an empty hashmap with pre-allocated space for the given
/// capacity.
pub fn with_capacity(capacity: usize) -> Self {
Self {
raw: RawTable::with_capacity(capacity),
raw: HashTable::with_capacity(capacity),
}
}
}
Expand All @@ -89,17 +89,14 @@ impl<K, V> CtxHashMap<K, V> {
Ctx: CtxEq<K, K> + CtxHash<K>,
{
let hash = compute_hash(ctx, &k);
match self.raw.find(hash as u64, |bucket| {
match self.raw.find_mut(hash as u64, |bucket| {
hash == bucket.hash && ctx.ctx_eq(&bucket.k, &k)
}) {
Some(bucket) => {
let data = unsafe { bucket.as_mut() };
Some(std::mem::replace(&mut data.v, v))
}
Some(bucket) => Some(std::mem::replace(&mut bucket.v, v)),
None => {
let data = BucketData { hash, k, v };
self.raw
.insert_entry(hash as u64, data, |bucket| bucket.hash as u64);
.insert_unique(hash as u64, data, |bucket| bucket.hash as u64);
None
}
}
Expand All @@ -115,10 +112,7 @@ impl<K, V> CtxHashMap<K, V> {
.find(hash as u64, |bucket| {
hash == bucket.hash && ctx.ctx_eq(&bucket.k, k)
})
.map(|bucket| {
let data = unsafe { bucket.as_ref() };
&data.v
})
.map(|bucket| &bucket.v)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ gimli = { workspace = true, optional = true }
addr2line = { workspace = true, optional = true }
semver = { workspace = true, optional = true }
smallvec = { workspace = true, optional = true }
hashbrown = { workspace = true, features = ["ahash"] }
hashbrown = { workspace = true, features = ["default-hasher"] }
bitflags = { workspace = true }

[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
Expand Down

0 comments on commit f2fb00d

Please sign in to comment.