branchless partition3_sp2 - only half is branchless but already faster
This commit is contained in:
parent
5d6ea0e778
commit
09ed5dd548
9
qsort.h
9
qsort.h
@ -258,10 +258,11 @@ static inline pret3 partition3_sp2(uint32_t array[], int low, int high, uint32_t
|
|||||||
while(jl <= jr) {
|
while(jl <= jr) {
|
||||||
/* 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)) {
|
||||||
if(array[jl] != pivotval) {
|
int isNonPivot = (array[jl] != pivotval);
|
||||||
if(++il != jl)
|
int nonSameIndex = (il + 1 != jl);
|
||||||
swapit(&array[il], &array[jl]);
|
if(isNonPivot & nonSameIndex)
|
||||||
}
|
swapit(&array[il + 1], &array[jl]);
|
||||||
|
il += isNonPivot & nonSameIndex;
|
||||||
++jl;
|
++jl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user