@@ -1509,19 +1509,21 @@ impl RawTableInner {
15091509
15101510 let ptr: NonNull < u8 > = match do_alloc ( alloc, layout) {
15111511 Ok ( block) => {
1512- // Utilize over-sized allocations.
1513- let x = maximum_buckets_in ( block. len ( ) , table_layout, Group :: WIDTH ) ;
1514- debug_assert ! ( x >= buckets) ;
1515- // Calculate the new ctrl_offset.
1516- let ( _oversized_layout, oversized_ctrl_offset) =
1517- match table_layout. calculate_layout_for ( x) {
1518- Some ( lco) => lco,
1519- None => unsafe { hint:: unreachable_unchecked ( ) } ,
1520- } ;
1521- debug_assert ! ( _oversized_layout. size( ) <= block. len( ) ) ;
1522- debug_assert ! ( oversized_ctrl_offset >= ctrl_offset) ;
1523- ctrl_offset = oversized_ctrl_offset;
1524- buckets = x;
1512+ if block. len ( ) > layout. size ( ) {
1513+ // Utilize over-sized allocations.
1514+ let x = maximum_buckets_in ( block. len ( ) , table_layout, Group :: WIDTH ) ;
1515+ debug_assert ! ( x >= buckets) ;
1516+ // Calculate the new ctrl_offset.
1517+ let ( _oversized_layout, oversized_ctrl_offset) =
1518+ match table_layout. calculate_layout_for ( x) {
1519+ Some ( lco) => lco,
1520+ None => unsafe { hint:: unreachable_unchecked ( ) } ,
1521+ } ;
1522+ debug_assert ! ( _oversized_layout. size( ) <= block. len( ) ) ;
1523+ debug_assert ! ( oversized_ctrl_offset >= ctrl_offset) ;
1524+ ctrl_offset = oversized_ctrl_offset;
1525+ buckets = x;
1526+ }
15251527
15261528 block. cast ( )
15271529 }
0 commit comments