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