mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Use new overflow-safe integer comparison functions.
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
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
|
||||
#include "_int.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "common/int.h"
|
||||
#include "lib/qunique.h"
|
||||
|
||||
/* arguments are assumed sorted & unique-ified */
|
||||
@ -396,15 +397,11 @@ int_to_intset(int32 elem)
|
||||
int
|
||||
compASC(const void *a, const void *b)
|
||||
{
|
||||
if (*(const int32 *) a == *(const int32 *) b)
|
||||
return 0;
|
||||
return (*(const int32 *) a > *(const int32 *) b) ? 1 : -1;
|
||||
return pg_cmp_s32(*(const int32 *) a, *(const int32 *) b);
|
||||
}
|
||||
|
||||
int
|
||||
compDESC(const void *a, const void *b)
|
||||
{
|
||||
if (*(const int32 *) a == *(const int32 *) b)
|
||||
return 0;
|
||||
return (*(const int32 *) a < *(const int32 *) b) ? 1 : -1;
|
||||
return pg_cmp_s32(*(const int32 *) b, *(const int32 *) a);
|
||||
}
|
||||
|
Reference in New Issue
Block a user