Remove sample based image hashing to avoid false equalities (#3980)

* Remove sample based image hashing to avoid false equalities

This was originally introduced to improve the performance of working with
image data, but since the memo hash wrapper got introduced this should no
longer be really necessary.

* Fix todo comment
This commit is contained in:
Dennis Kobert 2026-04-04 13:46:08 +02:00 committed by GitHub
parent bf269d7693
commit 19aaeb374b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 7 deletions

View File

@ -109,17 +109,11 @@ impl<P: Copy + Pixel> BitmapMut for Image<P> {
}
}
// TODO: Evaluate if this will be a problem for our use case.
/// Warning: This is an approximation of a hash, and is not guaranteed to not collide.
impl<P: Hash + Pixel> Hash for Image<P> {
fn hash<H: Hasher>(&self, state: &mut H) {
const HASH_SAMPLES: u64 = 1000;
let data_length = self.data.len() as u64;
self.width.hash(state);
self.height.hash(state);
for i in 0..HASH_SAMPLES.min(data_length) {
self.data[(i * data_length / HASH_SAMPLES) as usize].hash(state);
}
self.data.hash(state);
}
}