bugfixed branchless code having extra nonSameIndex - but was working when only half of it is branchless
This commit is contained in:
parent
09ed5dd548
commit
0b864ad2f0
11
qsort.h
11
qsort.h
@ -262,16 +262,17 @@ static inline pret3 partition3_sp2(uint32_t array[], int low, int high, uint32_t
|
|||||||
int nonSameIndex = (il + 1 != jl);
|
int nonSameIndex = (il + 1 != jl);
|
||||||
if(isNonPivot & nonSameIndex)
|
if(isNonPivot & nonSameIndex)
|
||||||
swapit(&array[il + 1], &array[jl]);
|
swapit(&array[il + 1], &array[jl]);
|
||||||
il += isNonPivot & nonSameIndex;
|
il += isNonPivot;
|
||||||
++jl;
|
++jl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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)) {
|
||||||
if(array[jr] != pivotval) {
|
int isNonPivot = (array[jr] != pivotval);
|
||||||
if(--ir != jr)
|
int nonSameIndex = (ir - 1 != jr);
|
||||||
swapit(&array[ir], &array[jr]);
|
if(isNonPivot & nonSameIndex)
|
||||||
}
|
swapit(&array[ir - 1], &array[jr]);
|
||||||
|
ir -= isNonPivot;
|
||||||
--jr;
|
--jr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user