Revert "try simpler branchless at cost of extra swaps - seems slower for me"

This reverts commit d61d1e72d291a4dbeb9197844a44897ac4027db9.
This commit is contained in:
Richard Thier 2025-05-06 02:30:56 +02:00
parent d61d1e72d2
commit bcc4f3bb62

View File

@ -259,7 +259,9 @@ static inline pret3 partition3_sp2(uint32_t array[], int low, int high, uint32_t
/* Handle left and find wrongly placed element */
while((array[jl] <= pivotval) && (jl <= jr)) {
int isNonPivot = (array[jl] != pivotval);
if(isNonPivot) swapit(&array[il + 1], &array[jl]);
int nonSameIndex = (il + 1 != jl);
if(isNonPivot & nonSameIndex)
swapit(&array[il + 1], &array[jl]);
il += isNonPivot;
++jl;
}
@ -267,7 +269,9 @@ static inline pret3 partition3_sp2(uint32_t array[], int low, int high, uint32_t
/* Handle right and find wrongly placed element */
while((array[jr] >= pivotval) && (jl <= jr)) {
int isNonPivot = (array[jr] != pivotval);
if(isNonPivot) swapit(&array[ir - 1], &array[jr]);
int nonSameIndex = (ir - 1 != jr);
if(isNonPivot & nonSameIndex)
swapit(&array[ir - 1], &array[jr]);
ir -= isNonPivot;
--jr;
}