From 4cf1553d9fda452188fb991ad3e6120e7cb31e2a Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Fri, 20 Dec 2024 00:19:22 +0500 Subject: [PATCH v6 2/4] Use PREPAREARR where possible --- contrib/intarray/_int_gist.c | 3 +-- contrib/intarray/_int_op.c | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c index a09b7fa812..ed66abe5a8 100644 --- a/contrib/intarray/_int_gist.c +++ b/contrib/intarray/_int_gist.c @@ -150,8 +150,7 @@ g_int_union(PG_FUNCTION_ARGS) ptr += nel; } - QSORT(res, 1); - res = _int_unique(res); + PREPAREARR(res); *size = VARSIZE(res); PG_RETURN_POINTER(res); } diff --git a/contrib/intarray/_int_op.c b/contrib/intarray/_int_op.c index 5b164f6788..0025cd3937 100644 --- a/contrib/intarray/_int_op.c +++ b/contrib/intarray/_int_op.c @@ -381,8 +381,8 @@ intset_union_elem(PG_FUNCTION_ARGS) result = intarray_add_elem(a, PG_GETARG_INT32(1)); PG_FREE_IF_COPY(a, 0); - QSORT(result, 1); - PG_RETURN_POINTER(_int_unique(result)); + PREPAREARR(result); + PG_RETURN_POINTER(result); } Datum @@ -403,11 +403,9 @@ intset_subtract(PG_FUNCTION_ARGS) CHECKARRVALID(a); CHECKARRVALID(b); - QSORT(a, 1); - a = _int_unique(a); + PREPAREARR(a); ca = ARRNELEMS(a); - QSORT(b, 1); - b = _int_unique(b); + PREPAREARR(b); cb = ARRNELEMS(b); result = new_intArrayType(ca); aa = ARRPTR(a); -- 2.39.5 (Apple Git-154)