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

Update hashbrown #379

Merged
merged 2 commits into from
Oct 13, 2024
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ row-serialize = ["serde"]

[dependencies]
hecs-macros = { path = "macros", version = "0.10.0", optional = true }
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }
hashbrown = { version = "0.15", default-features = false, features = ["default-hasher", "inline-more"] }
serde = { version = "1.0.117", default-features = false, optional = true }
spin = { version = "0.9.8", default-features = false, features = ["mutex", "spin_mutex", "lazy"] }
foldhash = { version = "0.1.3", default-features = false }

[dev-dependencies]
bencher = "0.1.5"
Expand Down
4 changes: 2 additions & 2 deletions src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::hash::{BuildHasher, BuildHasherDefault, Hasher};
use core::ops::{Deref, DerefMut};
use core::ptr::{self, NonNull};

use hashbrown::{hash_map::DefaultHashBuilder, HashMap};
use hashbrown::HashMap;

use crate::borrow::AtomicBorrow;
use crate::query::Fetch;
Expand Down Expand Up @@ -476,7 +476,7 @@ impl Hasher for TypeIdHasher {

// This will only be called if TypeId is neither u64 nor u128, which is not anticipated.
// In that case we'll just fall back to using a different hash implementation.
let mut hasher = <DefaultHashBuilder as BuildHasher>::Hasher::default();
let mut hasher = foldhash::fast::FixedState::with_seed(0xb334867b740a29a5).build_hasher();
hasher.write(bytes);
self.hash = hasher.finish();
}
Expand Down
4 changes: 2 additions & 2 deletions src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use core::sync::atomic::{AtomicUsize, Ordering};

/// A bit mask used to signal the `AtomicBorrow` has an active mutable borrow.
const UNIQUE_BIT: usize = !(usize::max_value() >> 1);
const UNIQUE_BIT: usize = !(usize::MAX >> 1);

const COUNTER_MASK: usize = usize::max_value() >> 1;
const COUNTER_MASK: usize = usize::MAX >> 1;

/// An atomic integer used to dynamicaly enforce borrowing rules
///
Expand Down
1 change: 1 addition & 0 deletions src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ macro_rules! tuple_impl {
}
}

#[allow(clippy::zero_repeat_side_effects)]
unsafe impl<$($name: Component),*> Bundle for ($($name,)*) {
fn with_static_ids<T>(f: impl FnOnce(&[TypeId]) -> T) -> T {
const N: usize = count!($($name),*);
Expand Down
4 changes: 2 additions & 2 deletions src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl Entities {
{
return Ok(Location {
archetype: 0,
index: u32::max_value(),
index: u32::MAX,
});
} else {
return Err(NoSuchEntity);
Expand Down Expand Up @@ -545,7 +545,7 @@ impl EntityMeta {
},
location: Location {
archetype: 0,
index: u32::max_value(), // dummy value, to be filled in
index: u32::MAX, // dummy value, to be filled in
},
};
}
Expand Down