From 78eaad5fb0ae0cd1682caab0895af633285ce173 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Mon, 17 Jun 2024 07:28:18 +0200 Subject: [PATCH] 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. --- core/src/slice/sort/shared/smallsort.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/slice/sort/shared/smallsort.rs b/core/src/slice/sort/shared/smallsort.rs index e208f7143d441..567a7090ecd7d 100644 --- a/core/src/slice/sort/shared/smallsort.rs +++ b/core/src/slice/sort/shared/smallsort.rs @@ -146,7 +146,9 @@ impl UnstableSmallSortFreezeTypeImpl for T { if has_efficient_in_place_swap::() && (mem::size_of::() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { - SMALL_SORT_NETWORK_SCRATCH_LEN + SMALL_SORT_NETWORK_THRESHOLD + } else if (mem::size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { + SMALL_SORT_GENERAL_THRESHOLD } else { SMALL_SORT_FALLBACK_THRESHOLD } @@ -161,6 +163,8 @@ impl UnstableSmallSortFreezeTypeImpl for T { && (mem::size_of::() * SMALL_SORT_NETWORK_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { small_sort_network(v, is_less); + } else if (mem::size_of::() * SMALL_SORT_GENERAL_SCRATCH_LEN) <= MAX_STACK_ARRAY_SIZE { + small_sort_general(v, is_less); } else { small_sort_fallback(v, is_less); }