From 3b42bdb47169c617cb79123c407a19d16458b49a Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Fri, 16 Feb 2024 14:05:36 -0600 Subject: Use new overflow-safe integer comparison functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 6b80394781 introduced integer comparison functions designed to be as efficient as possible while avoiding overflow. This commit makes use of these functions in many of the in-tree qsort() comparators to help ensure transitivity. Many of these comparator functions should also see a small performance boost. Author: Mats Kindahl Reviewed-by: Andres Freund, Fabrízio de Royes Mello Discussion: https://postgr.es/m/CA%2B14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw%40mail.gmail.com --- src/backend/parser/parse_agg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/backend/parser/parse_agg.c') diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 7b211a7743f..9d151a880b8 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -18,6 +18,7 @@ #include "catalog/pg_aggregate.h" #include "catalog/pg_constraint.h" #include "catalog/pg_type.h" +#include "common/int.h" #include "nodes/makefuncs.h" #include "nodes/nodeFuncs.h" #include "optimizer/optimizer.h" @@ -1760,7 +1761,7 @@ cmp_list_len_asc(const ListCell *a, const ListCell *b) int la = list_length((const List *) lfirst(a)); int lb = list_length((const List *) lfirst(b)); - return (la > lb) ? 1 : (la == lb) ? 0 : -1; + return pg_cmp_s32(la, lb); } /* list_sort comparator to sort sub-lists by length and contents */ -- cgit v1.2.3