From 362bfc14304e684d4354cb42e2170df353746559 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Tue, 16 May 2023 20:18:08 +0100 Subject: [PATCH] Explicity wrap the multiplication --- agb-hashmap/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/agb-hashmap/src/lib.rs b/agb-hashmap/src/lib.rs index ecf8241a..62839ea7 100644 --- a/agb-hashmap/src/lib.rs +++ b/agb-hashmap/src/lib.rs @@ -33,6 +33,7 @@ use core::{ fmt::Debug, hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, iter::FromIterator, + num::Wrapping, ops::Index, }; @@ -923,14 +924,15 @@ impl HashType { } // 32 bit mix function from here: https://github.com/skeeto/hash-prospector - fn bit_mix(mut key: u32) -> Self { + fn bit_mix(key: u32) -> Self { + let mut key = Wrapping(key); key ^= key >> 16; key *= 0x7feb352d; key ^= key >> 15; key *= 0x846ca68b; key ^= key >> 16; - Self(key) + Self(key.0) } pub(crate) fn fast_mod(self, len: usize) -> usize {