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:
parent
bf269d7693
commit
19aaeb374b
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue