aboutsummaryrefslogtreecommitdiff
path: root/contrib/intarray/_int_tool.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/intarray/_int_tool.c')
-rw-r--r--contrib/intarray/_int_tool.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c
index efff81d77dc..e5f4bd40643 100644
--- a/contrib/intarray/_int_tool.c
+++ b/contrib/intarray/_int_tool.c
@@ -7,6 +7,7 @@
#include "_int.h"
#include "catalog/pg_type.h"
+#include "lib/qunique.h"
/* arguments are assumed sorted & unique-ified */
bool
@@ -308,23 +309,13 @@ internal_size(int *a, int len)
ArrayType *
_int_unique(ArrayType *r)
{
- int *tmp,
- *dr,
- *data;
int num = ARRNELEMS(r);
+ bool duplicates_found; /* not used */
- if (num < 2)
- return r;
+ num = qunique_arg(ARRPTR(r), num, sizeof(int), isort_cmp,
+ &duplicates_found);
- data = tmp = dr = ARRPTR(r);
- while (tmp - data < num)
- {
- if (*tmp != *dr)
- *(++dr) = *tmp++;
- else
- tmp++;
- }
- return resize_intArrayType(r, dr + 1 - ARRPTR(r));
+ return resize_intArrayType(r, num);
}
void