mirror of
https://github.com/postgres/postgres.git
synced 2025-12-24 06:01:07 +03:00
Standardize on using the Min, Max, and Abs macros that are in our c.h file,
getting rid of numerous ad-hoc versions that have popped up in various places. Shortens code and avoids conflict with Windows min() and max() macros.
This commit is contained in:
@@ -361,7 +361,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
|
||||
_j = GETENTRY(entryvec, j);
|
||||
size_alpha = hemdist(datum_l, _j);
|
||||
size_beta = hemdist(datum_r, _j);
|
||||
costvector[j - 1].cost = abs(size_alpha - size_beta);
|
||||
costvector[j - 1].cost = Abs(size_alpha - size_beta);
|
||||
}
|
||||
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
|
||||
|
||||
|
||||
@@ -78,15 +78,6 @@ typedef struct
|
||||
|
||||
#define LQUERY_HASNOT 0x01
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef min
|
||||
#define min(a,b) ((a) <= (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef abs
|
||||
#define abs(a) ((a) < (0) ? -(a) : (a))
|
||||
#endif
|
||||
#define ISALNUM(x) ( isalnum((unsigned char)(x)) || (x) == '_' )
|
||||
|
||||
/* full text query */
|
||||
|
||||
@@ -259,7 +259,7 @@ ltree_penalty(PG_FUNCTION_ARGS)
|
||||
cmpl = ltree_compare(LTG_GETLNODE(origval), LTG_GETLNODE(newval));
|
||||
cmpr = ltree_compare(LTG_GETRNODE(newval), LTG_GETRNODE(origval));
|
||||
|
||||
*penalty = max(cmpl, 0) + max(cmpr, 0);
|
||||
*penalty = Max(cmpl, 0) + Max(cmpr, 0);
|
||||
|
||||
PG_RETURN_POINTER(penalty);
|
||||
}
|
||||
@@ -537,7 +537,7 @@ gist_tqcmp(ltree * t, lquery * q)
|
||||
while (an > 0 && bn > 0)
|
||||
{
|
||||
bl = LQL_FIRST(ql);
|
||||
if ((res = strncmp(al->name, bl->name, min(al->len, bl->len))) == 0)
|
||||
if ((res = strncmp(al->name, bl->name, Min(al->len, bl->len))) == 0)
|
||||
{
|
||||
if (al->len != bl->len)
|
||||
return al->len - bl->len;
|
||||
|
||||
@@ -55,7 +55,7 @@ ltree_compare(const ltree * a, const ltree * b)
|
||||
|
||||
while (an > 0 && bn > 0)
|
||||
{
|
||||
if ((res = strncmp(al->name, bl->name, min(al->len, bl->len))) == 0)
|
||||
if ((res = strncmp(al->name, bl->name, Min(al->len, bl->len))) == 0)
|
||||
{
|
||||
if (al->len != bl->len)
|
||||
return (al->len - bl->len) * 10 * (an + 1);
|
||||
@@ -443,7 +443,7 @@ lca_inner(ltree ** a, int len)
|
||||
l2 = LTREE_FIRST(*ptr);
|
||||
tmp = num;
|
||||
num = 0;
|
||||
for (i = 0; i < min(tmp, (*ptr)->numlevel - 1); i++)
|
||||
for (i = 0; i < Min(tmp, (*ptr)->numlevel - 1); i++)
|
||||
{
|
||||
if (l1->len == l2->len && strncmp(l1->name, l2->name, l1->len) == 0)
|
||||
num = i + 1;
|
||||
|
||||
Reference in New Issue
Block a user