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/replication/logical/reorderbuffer.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/backend/replication/logical/reorderbuffer.c') diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index bbf0966182f..5446df3c647 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -91,6 +91,7 @@ #include "access/xact.h" #include "access/xlog_internal.h" #include "catalog/catalog.h" +#include "common/int.h" #include "lib/binaryheap.h" #include "miscadmin.h" #include "pgstat.h" @@ -5119,11 +5120,7 @@ file_sort_by_lsn(const ListCell *a_p, const ListCell *b_p) RewriteMappingFile *a = (RewriteMappingFile *) lfirst(a_p); RewriteMappingFile *b = (RewriteMappingFile *) lfirst(b_p); - if (a->lsn < b->lsn) - return -1; - else if (a->lsn > b->lsn) - return 1; - return 0; + return pg_cmp_u64(a->lsn, b->lsn); } /* -- cgit v1.2.3