From 283783bf9b81f7c6cf790151f05c870518082bb7 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Fri, 9 May 2025 02:44:56 +0200 Subject: [PATCH] Revert "schwab: tried to help a bit with ILP - does not seem to help at all" This reverts commit bf9c22f4ecd37039fe69142e9b72db6eb50b82a9. --- schwab_sort.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/schwab_sort.h b/schwab_sort.h index 169cb90..36bd2d6 100644 --- a/schwab_sort.h +++ b/schwab_sort.h @@ -3,7 +3,7 @@ /* A fast quicksort-like new alg created in Csolnok, Hungary with: * - 4-way partitioning with 0..5 copies (not swaps) per elem per run - * - "Practically ensures" O(log2(n)) recursion depth + * - ensured O(log2(n)) worst recursion depth * * LICENCE: CC-BY, 2025 May 08-09 * Author: Richárd István Thier (also author of the Magyarsort) @@ -164,20 +164,23 @@ static inline int schwab_partition( * This is likely faster than calling a memcpy if we code this for not just uint32s! */ if(curr < klo) { - arr[b3] = arr[b2++]; - arr[b2 - 1] = arr[b1++]; - arr[b1 - 1] = arr[b0++]; - arr[b0 - 1] = curr; + arr[b3] = arr[b2]; + arr[b2] = arr[b1]; + arr[b1] = arr[b0]; + arr[b0] = curr; + ++b0; ++b1; ++b2; continue; } if(curr < kmid) { - arr[b3] = arr[b2++]; - arr[b2 - 1] = arr[b1++]; - arr[b1 - 1] = curr; + arr[b3] = arr[b2]; + arr[b2] = arr[b1]; + arr[b1] = curr; + ++b1; ++b2; } else { - arr[b3] = arr[b2++]; - arr[b2 - 1] = curr; + arr[b3] = arr[b2]; + arr[b2] = curr; + ++b2; } }