From 6ad8a2477a86b7f5401570ed504890b8df3fd9dc Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 13 Oct 2024 11:48:49 -0700 Subject: [PATCH 1/2] Update hashbrown --- Cargo.toml | 3 ++- src/archetype.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7ccd1723..c040a710 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/archetype.rs b/src/archetype.rs index d7b844cf..cc66b448 100644 --- a/src/archetype.rs +++ b/src/archetype.rs @@ -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; @@ -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 = ::Hasher::default(); + let mut hasher = foldhash::fast::FixedState::with_seed(0xb334867b740a29a5).build_hasher(); hasher.write(bytes); self.hash = hasher.finish(); } From 9216bac8d196059653d457c71471822a1034b4ae Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 13 Oct 2024 11:50:58 -0700 Subject: [PATCH 2/2] Fix lints --- src/borrow.rs | 4 ++-- src/bundle.rs | 1 + src/entities.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/borrow.rs b/src/borrow.rs index 32255579..be69de5b 100644 --- a/src/borrow.rs +++ b/src/borrow.rs @@ -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 /// diff --git a/src/bundle.rs b/src/bundle.rs index 842a3b50..6fad1839 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -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(f: impl FnOnce(&[TypeId]) -> T) -> T { const N: usize = count!($($name),*); diff --git a/src/entities.rs b/src/entities.rs index d3f36d63..575f062b 100644 --- a/src/entities.rs +++ b/src/entities.rs @@ -451,7 +451,7 @@ impl Entities { { return Ok(Location { archetype: 0, - index: u32::max_value(), + index: u32::MAX, }); } else { return Err(NoSuchEntity); @@ -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 }, }; }