diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-18 17:33:13 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-18 17:33:13 +0100 |
| commit | 61d1e1a6831113143c5d1e9f8ccf2a86f90f359a (patch) | |
| tree | 27c85e1ee876941bba558bb187885ccc4a76f87d /src/util | |
| parent | e01970b20a058ab1b4ebea916f229c9b706c84e4 (diff) | |
Remove layout-cache feature
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/prehashed.rs | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/util/prehashed.rs b/src/util/prehashed.rs index 866bda5b..79455918 100644 --- a/src/util/prehashed.rs +++ b/src/util/prehashed.rs @@ -1,15 +1,12 @@ +use std::any::Any; use std::fmt::{self, Debug, Formatter}; use std::hash::{Hash, Hasher}; use std::ops::Deref; -#[cfg(feature = "layout-cache")] -use std::any::Any; - /// A wrapper around a type that precomputes its hash. #[derive(Copy, Clone)] pub struct Prehashed<T: ?Sized> { /// The precomputed hash. - #[cfg(feature = "layout-cache")] hash: u64, /// The wrapped item. item: T, @@ -19,7 +16,6 @@ impl<T: Hash + 'static> Prehashed<T> { /// Compute an item's hash and wrap it. pub fn new(item: T) -> Self { Self { - #[cfg(feature = "layout-cache")] hash: { // Also hash the TypeId because the type might be converted // through an unsized coercion. @@ -52,23 +48,16 @@ impl<T: Debug + ?Sized> Debug for Prehashed<T> { } } -impl<T: Hash + ?Sized> Hash for Prehashed<T> { +impl<T: ?Sized> Hash for Prehashed<T> { fn hash<H: Hasher>(&self, state: &mut H) { - // Hash the node. - #[cfg(feature = "layout-cache")] state.write_u64(self.hash); - #[cfg(not(feature = "layout-cache"))] - self.item.hash(state); } } impl<T: Eq + ?Sized> Eq for Prehashed<T> {} -impl<T: PartialEq + ?Sized> PartialEq for Prehashed<T> { +impl<T: ?Sized> PartialEq for Prehashed<T> { fn eq(&self, other: &Self) -> bool { - #[cfg(feature = "layout-cache")] - return self.hash == other.hash; - #[cfg(not(feature = "layout-cache"))] - self.item.eq(&other.item) + self.hash == other.hash } } |
