|
@@ -12,7 +12,7 @@ extern "C" {
|
|
|
do { \
|
|
do { \
|
|
|
T* __first = ptr; \
|
|
T* __first = ptr; \
|
|
|
int __len = count; \
|
|
int __len = count; \
|
|
|
- while(__len != 0) { \
|
|
|
|
|
|
|
+ while(__len > 8) { \
|
|
|
int __l2 = __len >> 1; \
|
|
int __l2 = __len >> 1; \
|
|
|
T* __m = __first + __l2; \
|
|
T* __m = __first + __l2; \
|
|
|
if(less((*__m), (key))) { \
|
|
if(less((*__m), (key))) { \
|
|
@@ -22,6 +22,10 @@ extern "C" {
|
|
|
__len = __l2; \
|
|
__len = __l2; \
|
|
|
} \
|
|
} \
|
|
|
} \
|
|
} \
|
|
|
|
|
+ while(__len && less(*__first, (key))) { \
|
|
|
|
|
+ ++__first; \
|
|
|
|
|
+ --__len; \
|
|
|
|
|
+ } \
|
|
|
*(out_index) = __first - (T*)(ptr); \
|
|
*(out_index) = __first - (T*)(ptr); \
|
|
|
} while(0)
|
|
} while(0)
|
|
|
|
|
|
|
@@ -30,7 +34,8 @@ extern "C" {
|
|
|
* @param ptr Pointer to the first element of the array.
|
|
* @param ptr Pointer to the first element of the array.
|
|
|
* @param count Number of elements in the array.
|
|
* @param count Number of elements in the array.
|
|
|
* @param elem_size Size of each element in the array.
|
|
* @param elem_size Size of each element in the array.
|
|
|
- * @param cmp Comparison function that takes two elements and returns an integer similar to `strcmp`.
|
|
|
|
|
|
|
+ * @param cmp Comparison function that takes two elements and returns an integer similar to
|
|
|
|
|
+ * `strcmp`.
|
|
|
*/
|
|
*/
|
|
|
void c11__stable_sort(void* ptr,
|
|
void c11__stable_sort(void* ptr,
|
|
|
int count,
|
|
int count,
|