Index: contrib/intarray/_int_tool.c =================================================================== RCS file: /projects/cvsroot/pgsql/contrib/intarray/_int_tool.c,v retrieving revision 1.6 diff -c -r1.6 _int_tool.c *** contrib/intarray/_int_tool.c 19 Nov 2005 03:00:09 -0000 1.6 --- contrib/intarray/_int_tool.c 7 May 2006 09:59:09 -0000 *************** *** 183,221 **** return; } - - /* len >= 2 */ - bool - isort(int4 *a, int len) - { - int4 tmp, - index; - int4 *cur, - *end; - bool r = FALSE; - - end = a + len; - do - { - index = 0; - cur = a + 1; - while (cur < end) - { - if (*(cur - 1) > *cur) - { - tmp = *(cur - 1); - *(cur - 1) = *cur; - *cur = tmp; - index = 1; - } - else if (!r && *(cur - 1) == *cur) - r = TRUE; - cur++; - } - } while (index); - return r; - } - ArrayType * new_intArrayType(int num) { --- 183,188 ---- Index: contrib/intarray/_int.h =================================================================== RCS file: /projects/cvsroot/pgsql/contrib/intarray/_int.h,v retrieving revision 1.9 diff -c -r1.9 _int.h *** contrib/intarray/_int.h 3 May 2006 16:31:07 -0000 1.9 --- contrib/intarray/_int.h 7 May 2006 09:59:10 -0000 *************** *** 38,56 **** #define ARRISVOID(x) ((x) == NULL || ARRNELEMS(x) == 0) - #define SORT(x) \ - do { \ - if ( ARRNELEMS( x ) > 1 ) \ - isort( ARRPTR( x ), ARRNELEMS( x ) ); \ - } while(0) - - #define PREPAREARR(x) \ - do { \ - if ( ARRNELEMS( x ) > 1 ) \ - if ( isort( ARRPTR( x ), ARRNELEMS( x ) ) ) \ - x = _int_unique( x ); \ - } while(0) - /* "wish" function */ #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) ) --- 38,43 ---- *************** *** 105,111 **** /* ** useful function */ - bool isort(int4 *a, const int len); ArrayType *new_intArrayType(int num); ArrayType *copy_intArrayType(ArrayType *a); ArrayType *resize_intArrayType(ArrayType *a, int num); --- 92,97 ---- *************** *** 171,173 **** --- 157,168 ---- if (ARRNELEMS(a) > 1) \ qsort((void*)ARRPTR(a), ARRNELEMS(a),sizeof(int4), \ (direction) ? compASC : compDESC ) + + #define SORT(x) QSORT(x, 1) + + #define PREPAREARR(x) \ + if (ARRNELEMS(x) > 1) \ + { \ + SORT(x); \ + x = _int_unique( x ); \ + }