Use UnhashMap for a few more maps

This avoids hashing data that's already hashed.
This commit is contained in:
Mark Rousskov
2024-01-17 17:09:04 -05:00
parent c58a5da7d4
commit 510fcd318b
4 changed files with 28 additions and 6 deletions

View File

@@ -75,11 +75,21 @@ impl fmt::LowerHex for Hash64 {
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
pub struct Hash128 {
inner: u128,
}
// We expect Hash128 to be well mixed. So there's no point in hashing both parts.
//
// This also allows using Hash128-containing types in UnHash-based hashmaps, which would otherwise
// debug_assert! that we're hashing more than a single u64.
impl std::hash::Hash for Hash128 {
fn hash<H: std::hash::Hasher>(&self, h: &mut H) {
h.write_u64(self.truncate().as_u64());
}
}
impl Hash128 {
#[inline]
pub fn truncate(self) -> Hash64 {