@@ -355,7 +355,7 @@ fn partition<T, F>(v: &mut [T], pivot: usize, is_less: &mut F) -> (usize, bool)
355
355
l += 1 ;
356
356
}
357
357
358
- // Find the last element lesser that the pivot.
358
+ // Find the last element smaller that the pivot.
359
359
while l < r && !is_less ( v. get_unchecked ( r - 1 ) , pivot) {
360
360
r -= 1 ;
361
361
}
@@ -472,7 +472,7 @@ fn choose_pivot<T, F>(v: &mut [T], is_less: &mut F) -> (usize, bool)
472
472
{
473
473
// Minimal length to choose the median-of-medians method.
474
474
// Shorter slices use the simple median-of-three method.
475
- const SHORTEST_MEDIAN_OF_MEDIANS : usize = 90 ;
475
+ const SHORTEST_MEDIAN_OF_MEDIANS : usize = 80 ;
476
476
// Maximal number of swaps that can be performed in this function.
477
477
const MAX_SWAPS : usize = 4 * 3 ;
478
478
@@ -539,7 +539,7 @@ fn recurse<'a, T, F>(mut v: &'a mut [T], is_less: &mut F, mut pred: Option<&'a T
539
539
where F : FnMut ( & T , & T ) -> bool
540
540
{
541
541
// Slices of up to this length get sorted using insertion sort.
542
- const MAX_INSERTION : usize = 16 ;
542
+ const MAX_INSERTION : usize = 20 ;
543
543
544
544
// True if the last partitioning was reasonably balanced.
545
545
let mut was_balanced = true ;
@@ -627,8 +627,8 @@ pub fn quicksort<T, F>(v: &mut [T], mut is_less: F)
627
627
return ;
628
628
}
629
629
630
- // Limit the number of imbalanced partitions to `floor(log2(len)) + 2 `.
631
- let limit = mem:: size_of :: < usize > ( ) * 8 - v. len ( ) . leading_zeros ( ) as usize + 1 ;
630
+ // Limit the number of imbalanced partitions to `floor(log2(len)) + 1 `.
631
+ let limit = mem:: size_of :: < usize > ( ) * 8 - v. len ( ) . leading_zeros ( ) as usize ;
632
632
633
633
recurse ( v, & mut is_less, None , limit) ;
634
634
}
0 commit comments