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`
This commit is contained in:
parent
17501d7e3e
commit
940b896cbb
2 changed files with 6 additions and 8 deletions
|
@ -45,16 +45,16 @@ impl Id {
|
||||||
|
|
||||||
/// Generate a new [`Id`] by hashing some source (e.g. a string or integer).
|
/// Generate a new [`Id`] by hashing some source (e.g. a string or integer).
|
||||||
pub fn new(source: impl std::hash::Hash) -> Id {
|
pub fn new(source: impl std::hash::Hash) -> Id {
|
||||||
use std::hash::Hasher;
|
use std::hash::{BuildHasher, Hasher};
|
||||||
let mut hasher = epaint::ahash::AHasher::default();
|
let mut hasher = epaint::ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher();
|
||||||
source.hash(&mut hasher);
|
source.hash(&mut hasher);
|
||||||
Id(hasher.finish())
|
Id(hasher.finish())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate a new [`Id`] by hashing the parent [`Id`] and the given argument.
|
/// Generate a new [`Id`] by hashing the parent [`Id`] and the given argument.
|
||||||
pub fn with(self, child: impl std::hash::Hash) -> Id {
|
pub fn with(self, child: impl std::hash::Hash) -> Id {
|
||||||
use std::hash::Hasher;
|
use std::hash::{BuildHasher, Hasher};
|
||||||
let mut hasher = epaint::ahash::AHasher::default();
|
let mut hasher = epaint::ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher();
|
||||||
hasher.write_u64(self.0);
|
hasher.write_u64(self.0);
|
||||||
child.hash(&mut hasher);
|
child.hash(&mut hasher);
|
||||||
Id(hasher.finish())
|
Id(hasher.finish())
|
||||||
|
|
|
@ -5,10 +5,8 @@ pub use ordered_float::*;
|
||||||
/// Hash the given value with a predictable hasher.
|
/// Hash the given value with a predictable hasher.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hash(value: impl std::hash::Hash) -> u64 {
|
pub fn hash(value: impl std::hash::Hash) -> u64 {
|
||||||
use std::hash::Hasher as _;
|
use ahash::RandomState;
|
||||||
let mut hasher = ahash::AHasher::default();
|
RandomState::with_seeds(1, 2, 3, 4).hash_one(value)
|
||||||
value.hash(&mut hasher);
|
|
||||||
hasher.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hash the given value with the given hasher.
|
/// Hash the given value with the given hasher.
|
||||||
|
|
Loading…
Reference in a new issue