@@ -109,26 +109,34 @@ const MAX_HASHED_BUFFER_LEN: usize = 2 * MAX_BYTES_TO_HASH;
109
109
// large.
110
110
impl hash:: Hash for Allocation {
111
111
fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
112
+ let Self {
113
+ bytes,
114
+ provenance,
115
+ init_mask,
116
+ align,
117
+ mutability,
118
+ extra : _, // don't bother hashing ()
119
+ } = self ;
120
+
112
121
// Partially hash the `bytes` buffer when it is large. To limit collisions with common
113
122
// prefixes and suffixes, we hash the length and some slices of the buffer.
114
- let byte_count = self . bytes . len ( ) ;
123
+ let byte_count = bytes. len ( ) ;
115
124
if byte_count > MAX_HASHED_BUFFER_LEN {
116
125
// Hash the buffer's length.
117
126
byte_count. hash ( state) ;
118
127
119
128
// And its head and tail.
120
- self . bytes [ ..MAX_BYTES_TO_HASH ] . hash ( state) ;
121
- self . bytes [ byte_count - MAX_BYTES_TO_HASH ..] . hash ( state) ;
129
+ bytes[ ..MAX_BYTES_TO_HASH ] . hash ( state) ;
130
+ bytes[ byte_count - MAX_BYTES_TO_HASH ..] . hash ( state) ;
122
131
} else {
123
- self . bytes . hash ( state) ;
132
+ bytes. hash ( state) ;
124
133
}
125
134
126
135
// Hash the other fields as usual.
127
- self . provenance . hash ( state) ;
128
- self . init_mask . hash ( state) ;
129
- self . align . hash ( state) ;
130
- self . mutability . hash ( state) ;
131
- self . extra . hash ( state) ;
136
+ provenance. hash ( state) ;
137
+ init_mask. hash ( state) ;
138
+ align. hash ( state) ;
139
+ mutability. hash ( state) ;
132
140
}
133
141
}
134
142
0 commit comments