try simpler branchless at cost of extra swaps - seems slower for me
This commit is contained in:
parent
0b864ad2f0
commit
d61d1e72d2
8
qsort.h
8
qsort.h
@ -259,9 +259,7 @@ 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);
|
||||||
int nonSameIndex = (il + 1 != jl);
|
if(isNonPivot) swapit(&array[il + 1], &array[jl]);
|
||||||
if(isNonPivot & nonSameIndex)
|
|
||||||
swapit(&array[il + 1], &array[jl]);
|
|
||||||
il += isNonPivot;
|
il += isNonPivot;
|
||||||
++jl;
|
++jl;
|
||||||
}
|
}
|
||||||
@ -269,9 +267,7 @@ 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);
|
||||||
int nonSameIndex = (ir - 1 != jr);
|
if(isNonPivot) swapit(&array[ir - 1], &array[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