Revert "try simpler branchless at cost of extra swaps - seems slower for me"
This reverts commit d61d1e72d291a4dbeb9197844a44897ac4027db9.
This commit is contained in:
parent
d61d1e72d2
commit
bcc4f3bb62
8
qsort.h
8
qsort.h
@ -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 */
|
/* Handle left and find wrongly placed element */
|
||||||
while((array[jl] <= pivotval) && (jl <= jr)) {
|
while((array[jl] <= pivotval) && (jl <= jr)) {
|
||||||
int isNonPivot = (array[jl] != pivotval);
|
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;
|
il += isNonPivot;
|
||||||
++jl;
|
++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 */
|
/* Handle right and find wrongly placed element */
|
||||||
while((array[jr] >= pivotval) && (jl <= jr)) {
|
while((array[jr] >= pivotval) && (jl <= jr)) {
|
||||||
int isNonPivot = (array[jr] != pivotval);
|
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;
|
ir -= isNonPivot;
|
||||||
--jr;
|
--jr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user