@@ -109,26 +109,34 @@ const MAX_HASHED_BUFFER_LEN: usize = 2 * MAX_BYTES_TO_HASH;
109109// large.
110110impl hash:: Hash for Allocation {
111111 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+
112121 // Partially hash the `bytes` buffer when it is large. To limit collisions with common
113122 // 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 ( ) ;
115124 if byte_count > MAX_HASHED_BUFFER_LEN {
116125 // Hash the buffer's length.
117126 byte_count. hash ( state) ;
118127
119128 // 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) ;
122131 } else {
123- self . bytes . hash ( state) ;
132+ bytes. hash ( state) ;
124133 }
125134
126135 // 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) ;
132140 }
133141}
134142
0 commit comments