]> granicus.if.org Git - php/commitdiff
Remove zend_qsort
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 12 May 2020 14:57:53 +0000 (16:57 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 12 May 2020 14:57:53 +0000 (16:57 +0200)
This has been superseded by zend_sort and is no longer used.

Zend/zend_sort.c
Zend/zend_sort.h

index 4fe3835edb0bbb6d62ca392b402d88e5c5d49425..355d2d1bad581fe63603ce94254c07f9db0ec2fc 100644 (file)
 #include "zend_sort.h"
 #include <limits.h>
 
-#define QSORT_STACK_SIZE (sizeof(size_t) * CHAR_BIT)
-
-ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare, swap_func_t swp) /* {{{ */
-{
-       void           *begin_stack[QSORT_STACK_SIZE];
-       void           *end_stack[QSORT_STACK_SIZE];
-       register char  *begin;
-       register char  *end;
-       register char  *seg1;
-       register char  *seg2;
-       register char  *seg2p;
-       register int    loop;
-       size_t          offset;
-
-       begin_stack[0] = (char *) base;
-       end_stack[0]   = (char *) base + ((nmemb - 1) * siz);
-
-       for (loop = 0; loop >= 0; --loop) {
-               begin = begin_stack[loop];
-               end   = end_stack[loop];
-
-               while (begin < end) {
-                       offset = (end - begin) >> Z_L(1);
-                       swp(begin, begin + (offset - (offset % siz)));
-
-                       seg1 = begin + siz;
-                       seg2 = end;
-
-                       while (1) {
-                               for (; seg1 < seg2 && compare(begin, seg1) > 0;
-                                    seg1 += siz);
-
-                               for (; seg2 >= seg1 && compare(seg2, begin) > 0;
-                                    seg2 -= siz);
-
-                               if (seg1 >= seg2)
-                                       break;
-
-                               swp(seg1, seg2);
-
-                               seg1 += siz;
-                               seg2 -= siz;
-                       }
-
-                       swp(begin, seg2);
-
-                       seg2p = seg2;
-
-                       if ((seg2p - begin) <= (end - seg2p)) {
-                               if ((seg2p + siz) < end) {
-                                       begin_stack[loop] = seg2p + siz;
-                                       end_stack[loop++] = end;
-                               }
-                               end = seg2p - siz;
-                       }
-                       else {
-                               if ((seg2p - siz) > begin) {
-                                       begin_stack[loop] = begin;
-                                       end_stack[loop++] = seg2p - siz;
-                               }
-                               begin = seg2p + siz;
-                       }
-               }
-       }
-}
-/* }}} */
-
 static inline void zend_sort_2(void *a, void *b, compare_func_t cmp, swap_func_t swp) /* {{{ */ {
        if (cmp(a, b) > 0) {
                swp(a, b);
index e2ef938df753fc0b0b0b3e9d7695ab889f4ce185..e606935f7902929478a9558a63f316076fc8a0f0 100644 (file)
@@ -21,7 +21,6 @@
 #define ZEND_SORT_H
 
 BEGIN_EXTERN_C()
-ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp);
 ZEND_API void zend_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp);
 ZEND_API void zend_insert_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp);
 END_EXTERN_C()