From 940b896cbba39eb04757b975f81d9b80e7e198ed Mon Sep 17 00:00:00 2001 From: axxop <53638052+axxop@users.noreply.github.com> Date: Mon, 7 Nov 2022 17:53:07 +0800 Subject: [PATCH] use `RandomState::with_seeds` replace `AHasher::default` (#2254) * use `RandomState::with_seeds` replace `AHasher::default` * remove history checkout * update seeds to `1,2,3,4` --- crates/egui/src/id.rs | 8 ++++---- crates/epaint/src/util/mod.rs | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/egui/src/id.rs b/crates/egui/src/id.rs index d4a52e77..94184e0a 100644 --- a/crates/egui/src/id.rs +++ b/crates/egui/src/id.rs @@ -45,16 +45,16 @@ impl Id { /// Generate a new [`Id`] by hashing some source (e.g. a string or integer). pub fn new(source: impl std::hash::Hash) -> Id { - use std::hash::Hasher; - let mut hasher = epaint::ahash::AHasher::default(); + use std::hash::{BuildHasher, Hasher}; + let mut hasher = epaint::ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher(); source.hash(&mut hasher); Id(hasher.finish()) } /// Generate a new [`Id`] by hashing the parent [`Id`] and the given argument. pub fn with(self, child: impl std::hash::Hash) -> Id { - use std::hash::Hasher; - let mut hasher = epaint::ahash::AHasher::default(); + use std::hash::{BuildHasher, Hasher}; + let mut hasher = epaint::ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher(); hasher.write_u64(self.0); child.hash(&mut hasher); Id(hasher.finish()) diff --git a/crates/epaint/src/util/mod.rs b/crates/epaint/src/util/mod.rs index 2b7e0c73..cb3bc66d 100644 --- a/crates/epaint/src/util/mod.rs +++ b/crates/epaint/src/util/mod.rs @@ -5,10 +5,8 @@ pub use ordered_float::*; /// Hash the given value with a predictable hasher. #[inline] pub fn hash(value: impl std::hash::Hash) -> u64 { - use std::hash::Hasher as _; - let mut hasher = ahash::AHasher::default(); - value.hash(&mut hasher); - hasher.finish() + use ahash::RandomState; + RandomState::with_seeds(1, 2, 3, 4).hash_one(value) } /// Hash the given value with the given hasher.