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) {
|
||||
/* Handle left and find wrongly placed element */
|
||||
while((array[jl] <= pivotval) && (jl <= jr)) {
|
||||
if(array[jl] != pivotval) {
|
||||
if(++il != jl)
|
||||
swapit(&array[il], &array[jl]);
|
||||
}
|
||||
int isNonPivot = (array[jl] != pivotval);
|
||||
int nonSameIndex = (il + 1 != jl);
|
||||
if(isNonPivot & nonSameIndex)
|
||||
swapit(&array[il + 1], &array[jl]);
|
||||
il += isNonPivot & nonSameIndex;
|
||||
++jl;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user