diff --git a/agb-hashmap/src/lib.rs b/agb-hashmap/src/lib.rs index 89f229fe..d7b8b254 100644 --- a/agb-hashmap/src/lib.rs +++ b/agb-hashmap/src/lib.rs @@ -907,7 +907,7 @@ const fn number_before_resize(capacity: usize) -> usize { capacity * 60 / 100 } -#[derive(Default, Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub(crate) struct HashType(u32); impl From for HashType { @@ -919,13 +919,17 @@ impl From for HashType { } impl HashType { + pub(crate) const fn new() -> Self { + Self(0) + } + // 32 bit mix function from here: https://gist.github.com/badboy/6267743 fn bit_mix(key: u32) -> Self { use core::num::Wrapping; let key = Wrapping(key); - let key = (key + Wrapping(0x7ed55d16u32)) + (key << 12); + let key = (key + Wrapping(0x7ed55d16)) + (key << 12); let key = (key ^ Wrapping(0xc761c23c)) ^ (key >> 19); let key = (key + Wrapping(0x165667b1)) + (key << 5); let key = (key + Wrapping(0xd3a2646c)) ^ (key << 9); diff --git a/agb-hashmap/src/node.rs b/agb-hashmap/src/node.rs index 29ed7efb..62aa4b1a 100644 --- a/agb-hashmap/src/node.rs +++ b/agb-hashmap/src/node.rs @@ -16,9 +16,9 @@ pub(crate) struct Node { } impl Node { - fn new() -> Self { + pub(crate) const fn new() -> Self { Self { - hash: HashType::default(), + hash: HashType::new(), distance_to_initial_bucket: -1, key: MaybeUninit::uninit(), value: MaybeUninit::uninit(), @@ -144,12 +144,6 @@ impl Drop for Node { } } -impl Default for Node { - fn default() -> Self { - Self::new() - } -} - impl Clone for Node where K: Clone, diff --git a/agb-hashmap/src/node_storage.rs b/agb-hashmap/src/node_storage.rs index 63d0609a..a49a5ef6 100644 --- a/agb-hashmap/src/node_storage.rs +++ b/agb-hashmap/src/node_storage.rs @@ -19,7 +19,7 @@ impl NodeStorage { let mut nodes = Vec::with_capacity_in(capacity, alloc); for _ in 0..capacity { - nodes.push(Node::default()); + nodes.push(Node::new()); } Self {