*** contrib/intarray.orig/_int.c	Thu Apr 17 12:35:40 2003
--- contrib/intarray/_int.c	Thu Apr 24 16:13:04 2003
***************
*** 967,972 ****
--- 967,974 ----
  	return size;
  }
  
+ #define UNIX_UNIQ(a) a = _int_unique(a)
+ 
  /* r is sorted and size of r > 1 */
  static ArrayType *
  _int_unique(ArrayType *r)
***************
*** 976,981 ****
--- 978,986 ----
  			   *data;
  	int			num = ARRNELEMS(r);
  
+ 	if ( num<2 )
+ 		return r;
+ 
  	data = tmp = dr = ARRPTR(r);
  	while (tmp - data < num)
  		if (*tmp != *dr)
***************
*** 2445,2467 ****
  	qsort((void*)ARRPTR(a), ARRNELEMS(a),sizeof(int4),	\
  		(direction) ? compASC : compDESC )
  
- #define UNIX_UNIQ(a) a = resize_intArrayType(a, unix_uniq(ARRPTR(a), ARRNELEMS(a)))
- 
- static int32
- unix_uniq(int32 *array, int32 count)
- {
- 	register int32 i,
- 				k = 0;
- 
- 	for (i = 1; i < count; i++)
- 		if (array[k] != array[i])
- 		{
- 			k++;
- 			if (i > k)
- 				array[k] = array[i];
- 		}
- 	return (k + 1);
- }
  
  Datum
  intset(PG_FUNCTION_ARGS)
--- 2450,2455 ----
