Bug fix: stop using AHasher for Id:s
AHasher does not produce same hashes efter e.g. restarting an app
This commit is contained in:
parent
ac03242ec3
commit
8163f912d3
3 changed files with 10 additions and 4 deletions
|
@ -41,15 +41,19 @@ impl Id {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(source: impl Hash) -> Id {
|
pub fn new(source: impl Hash) -> Id {
|
||||||
|
// NOTE: AHasher is NOT suitable for this!
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
let mut hasher = ahash::AHasher::default();
|
let mut hasher = DefaultHasher::default();
|
||||||
source.hash(&mut hasher);
|
source.hash(&mut hasher);
|
||||||
Id(hasher.finish())
|
Id(hasher.finish())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with(self, child: impl Hash) -> Id {
|
pub fn with(self, child: impl Hash) -> Id {
|
||||||
|
// NOTE: AHasher is NOT suitable for this!
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
let mut hasher = ahash::AHasher::default();
|
let mut hasher = DefaultHasher::default();
|
||||||
hasher.write_u64(self.0);
|
hasher.write_u64(self.0);
|
||||||
child.hash(&mut hasher);
|
child.hash(&mut hasher);
|
||||||
Id(hasher.finish())
|
Id(hasher.finish())
|
||||||
|
|
|
@ -134,7 +134,8 @@ impl Fonts {
|
||||||
let mut atlas = atlas.lock();
|
let mut atlas = atlas.lock();
|
||||||
let texture = atlas.texture_mut();
|
let texture = atlas.texture_mut();
|
||||||
// Make sure we seed the texture version with something unique based on the default characters:
|
// Make sure we seed the texture version with something unique based on the default characters:
|
||||||
let mut hasher = ahash::AHasher::default();
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
let mut hasher = DefaultHasher::default();
|
||||||
texture.pixels.hash(&mut hasher);
|
texture.pixels.hash(&mut hasher);
|
||||||
texture.version = hasher.finish();
|
texture.version = hasher.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash(value: impl Hash) -> u64 {
|
fn hash(value: impl Hash) -> u64 {
|
||||||
let mut hasher = ahash::AHasher::default();
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
let mut hasher = DefaultHasher::default();
|
||||||
value.hash(&mut hasher);
|
value.hash(&mut hasher);
|
||||||
hasher.finish()
|
hasher.finish()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue