From 92373649cba51cce56352134d17f21052dd0df17 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Mon, 2 Oct 2023 17:10:51 +0200 Subject: [PATCH] Rename MAX_LEN_SMALL_SORT -> SMALL_SORT_THRESHOLD --- src/drift.rs | 2 +- src/quicksort.rs | 2 +- src/smallsort.rs | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/drift.rs b/src/drift.rs index 6f043a0..b45cd4a 100644 --- a/src/drift.rs +++ b/src/drift.rs @@ -124,7 +124,7 @@ pub fn sort bool>( // as our threshold, as we will call small_sort on any runs smaller than this. const MIN_MERGE_SLICE_LEN: usize = 32; let min_good_run_len = if eager_sort { - T::MAX_LEN_SMALL_SORT + T::SMALL_SORT_THRESHOLD } else if len <= (MIN_MERGE_SLICE_LEN * MIN_MERGE_SLICE_LEN) { MIN_MERGE_SLICE_LEN } else { diff --git a/src/quicksort.rs b/src/quicksort.rs index a1df3c9..ee0cab3 100644 --- a/src/quicksort.rs +++ b/src/quicksort.rs @@ -20,7 +20,7 @@ pub fn stable_quicksort bool>( loop { let len = v.len(); - if len <= T::MAX_LEN_SMALL_SORT { + if len <= T::SMALL_SORT_THRESHOLD { T::sort_small(v, scratch, is_less); return; } diff --git a/src/smallsort.rs b/src/smallsort.rs index 1412017..66cdd3f 100644 --- a/src/smallsort.rs +++ b/src/smallsort.rs @@ -12,7 +12,7 @@ use core::ptr; // Use a trait to focus code-gen on only the parts actually relevant for the type. Avoid generating // LLVM-IR for the sorting-network and median-networks for types that don't qualify. pub trait SmallSortTypeImpl: Sized { - const MAX_LEN_SMALL_SORT: usize; + const SMALL_SORT_THRESHOLD: usize; /// Sorts `v` using strategies optimized for small sizes. fn sort_small bool>( @@ -23,7 +23,7 @@ pub trait SmallSortTypeImpl: Sized { } impl SmallSortTypeImpl for T { - default const MAX_LEN_SMALL_SORT: usize = 16; + default const SMALL_SORT_THRESHOLD: usize = 16; default fn sort_small bool>( v: &mut [T], @@ -36,14 +36,14 @@ impl SmallSortTypeImpl for T { } } -pub const MIN_SMALL_SORT_SCRATCH_LEN: usize = i32::MAX_LEN_SMALL_SORT + 16; +pub const MIN_SMALL_SORT_SCRATCH_LEN: usize = i32::SMALL_SORT_THRESHOLD + 16; impl SmallSortTypeImpl for T where T: crate::Freeze, (): crate::IsTrue<{ mem::size_of::() <= 96 }>, { - const MAX_LEN_SMALL_SORT: usize = 20; + const SMALL_SORT_THRESHOLD: usize = 20; fn sort_small bool>( v: &mut [T], @@ -70,14 +70,14 @@ where // SAFETY: scratch_base is valid and has enough space. sort8_stable( v_base, - scratch_base.add(T::MAX_LEN_SMALL_SORT), + scratch_base.add(T::SMALL_SORT_THRESHOLD), scratch_base, is_less, ); sort8_stable( v_base.add(len_div_2), - scratch_base.add(T::MAX_LEN_SMALL_SORT + 8), + scratch_base.add(T::SMALL_SORT_THRESHOLD + 8), scratch_base.add(len_div_2), is_less, );