@@ -717,26 +717,25 @@ fn calculate_offsets(hashes_size: usize,
717717 ( pairs_offset, end_of_pairs, oflo)
718718}
719719
720- // Returns a tuple of (minimum required malloc alignment, hash_offset,
720+ // Returns a tuple of (minimum required malloc alignment,
721721// array_size), from the start of a mallocated array.
722722fn calculate_allocation ( hash_size : usize ,
723723 hash_align : usize ,
724724 pairs_size : usize ,
725725 pairs_align : usize )
726- -> ( usize , usize , usize , bool ) {
727- let hash_offset = 0 ;
726+ -> ( usize , usize , bool ) {
728727 let ( _, end_of_pairs, oflo) = calculate_offsets ( hash_size, pairs_size, pairs_align) ;
729728
730729 let align = cmp:: max ( hash_align, pairs_align) ;
731730
732- ( align, hash_offset , end_of_pairs, oflo)
731+ ( align, end_of_pairs, oflo)
733732}
734733
735734#[ test]
736735fn test_offset_calculation ( ) {
737- assert_eq ! ( calculate_allocation( 128 , 8 , 16 , 8 ) , ( 8 , 0 , 144 , false ) ) ;
738- assert_eq ! ( calculate_allocation( 3 , 1 , 2 , 1 ) , ( 1 , 0 , 5 , false ) ) ;
739- assert_eq ! ( calculate_allocation( 6 , 2 , 12 , 4 ) , ( 4 , 0 , 20 , false ) ) ;
736+ assert_eq ! ( calculate_allocation( 128 , 8 , 16 , 8 ) , ( 8 , 144 , false ) ) ;
737+ assert_eq ! ( calculate_allocation( 3 , 1 , 2 , 1 ) , ( 1 , 5 , false ) ) ;
738+ assert_eq ! ( calculate_allocation( 6 , 2 , 12 , 4 ) , ( 4 , 20 , false ) ) ;
740739 assert_eq ! ( calculate_offsets( 128 , 15 , 4 ) , ( 128 , 143 , false ) ) ;
741740 assert_eq ! ( calculate_offsets( 3 , 2 , 4 ) , ( 4 , 6 , false ) ) ;
742741 assert_eq ! ( calculate_offsets( 6 , 12 , 4 ) , ( 8 , 20 , false ) ) ;
@@ -768,10 +767,10 @@ impl<K, V> RawTable<K, V> {
768767 // This is great in theory, but in practice getting the alignment
769768 // right is a little subtle. Therefore, calculating offsets has been
770769 // factored out into a different function.
771- let ( alignment, hash_offset , size, oflo) = calculate_allocation ( hashes_size,
772- align_of :: < HashUint > ( ) ,
773- pairs_size,
774- align_of :: < ( K , V ) > ( ) ) ;
770+ let ( alignment, size, oflo) = calculate_allocation ( hashes_size,
771+ align_of :: < HashUint > ( ) ,
772+ pairs_size,
773+ align_of :: < ( K , V ) > ( ) ) ;
775774 assert ! ( !oflo, "capacity overflow" ) ;
776775
777776 // One check for overflow that covers calculation and rounding of size.
@@ -784,7 +783,7 @@ impl<K, V> RawTable<K, V> {
784783 let buffer = Heap . alloc ( Layout :: from_size_align ( size, alignment) . unwrap ( ) )
785784 . unwrap_or_else ( |e| Heap . oom ( e) ) ;
786785
787- let hashes = buffer. offset ( hash_offset as isize ) as * mut HashUint ;
786+ let hashes = buffer as * mut HashUint ;
788787
789788 RawTable {
790789 capacity_mask : capacity. wrapping_sub ( 1 ) ,
@@ -1157,6 +1156,7 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
11571156 }
11581157
11591158 new_ht. size = self . size ( ) ;
1159+ new_ht. set_tag ( self . tag ( ) ) ;
11601160
11611161 new_ht
11621162 }
@@ -1183,10 +1183,10 @@ unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
11831183
11841184 let hashes_size = self . capacity ( ) * size_of :: < HashUint > ( ) ;
11851185 let pairs_size = self . capacity ( ) * size_of :: < ( K , V ) > ( ) ;
1186- let ( align, _ , size, oflo) = calculate_allocation ( hashes_size,
1187- align_of :: < HashUint > ( ) ,
1188- pairs_size,
1189- align_of :: < ( K , V ) > ( ) ) ;
1186+ let ( align, size, oflo) = calculate_allocation ( hashes_size,
1187+ align_of :: < HashUint > ( ) ,
1188+ pairs_size,
1189+ align_of :: < ( K , V ) > ( ) ) ;
11901190
11911191 debug_assert ! ( !oflo, "should be impossible" ) ;
11921192
0 commit comments