Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 78eaad5

Browse files
committedJun 17, 2024
Fix unintended regression for Freeze + Copy types
Freeze + Copy types should be allowed to choose between all three small-sort variants. With the recent changes to small-sort selection, a regression was added that only let such types choose between network and fallback. It can now also choose general where appropriate.
1 parent 48e1578 commit 78eaad5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎core/src/slice/sort/shared/smallsort.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ impl<T: FreezeMarker + CopyMarker> UnstableSmallSortFreezeTypeImpl for T {
146146
if has_efficient_in_place_swap::<T>()
147147
&& (mem::size_of::<T>() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE
148148
{
149-
SMALL_SORT_NETWORK_SCRATCH_LEN
149+
SMALL_SORT_NETWORK_THRESHOLD
150+
} else if (mem::size_of::<T>() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE {
151+
SMALL_SORT_GENERAL_THRESHOLD
150152
} else {
151153
SMALL_SORT_FALLBACK_THRESHOLD
152154
}
@@ -161,6 +163,8 @@ impl<T: FreezeMarker + CopyMarker> UnstableSmallSortFreezeTypeImpl for T {
161163
&& (mem::size_of::<T>() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE
162164
{
163165
small_sort_network(v, is_less);
166+
} else if (mem::size_of::<T>() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE {
167+
small_sort_general(v, is_less);
164168
} else {
165169
small_sort_fallback(v, is_less);
166170
}

0 commit comments

Comments
 (0)
Failed to load comments.