1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Modify LOOPBYTE/LOOPBIT macros to be more logical; rather than have the

for() body passed as a parameter, make the macros act as simple headers
to code blocks.

This allows pgindent to be run on these files.
This commit is contained in:
Bruce Momjian
2007-11-16 00:13:02 +00:00
parent 7d4c99b414
commit 224f91f66d
9 changed files with 191 additions and 204 deletions

View File

@ -118,10 +118,11 @@ _ltree_compress(PG_FUNCTION_ARGS)
BITVECP sign = LTG_SIGN(DatumGetPointer(entry->key));
ALOOPBYTE(
if ((sign[i] & 0xff) != 0xff)
PG_RETURN_POINTER(retval);
);
ALOOPBYTE
{
if ((sign[i] & 0xff) != 0xff)
PG_RETURN_POINTER(retval);
}
len = LTG_HDRSIZE;
key = (ltree_gist *) palloc(len);
SET_VARSIZE(key, len);
@ -155,13 +156,14 @@ _ltree_same(PG_FUNCTION_ARGS)
sb = LTG_SIGN(b);
*result = true;
ALOOPBYTE(
if (sa[i] != sb[i])
{
*result = false;
break;
ALOOPBYTE
{
if (sa[i] != sb[i])
{
*result = false;
break;
}
}
);
}
PG_RETURN_POINTER(result);
}
@ -175,9 +177,8 @@ unionkey(BITVECP sbase, ltree_gist * add)
if (LTG_ISALLTRUE(add))
return 1;
ALOOPBYTE(
sbase[i] |= sadd[i];
);
ALOOPBYTE
sbase[i] |= sadd[i];
return 0;
}
@ -219,9 +220,8 @@ sizebitvec(BITVECP sign)
int4 size = 0,
i;
ALOOPBYTE(
size += number_of_ones[(unsigned char) sign[i]];
);
ALOOPBYTE
size += number_of_ones[(unsigned char) sign[i]];
return size;
}
@ -232,10 +232,11 @@ hemdistsign(BITVECP a, BITVECP b)
diff,
dist = 0;
ALOOPBYTE(
diff = (unsigned char) (a[i] ^ b[i]);
dist += number_of_ones[diff];
);
ALOOPBYTE
{
diff = (unsigned char) (a[i] ^ b[i]);
dist += number_of_ones[diff];
}
return dist;
}
@ -410,9 +411,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
else
{
ptr = LTG_SIGN(_j);
ALOOPBYTE(
union_l[i] |= ptr[i];
);
ALOOPBYTE
union_l[i] |= ptr[i];
}
*left++ = j;
v->spl_nleft++;
@ -427,9 +427,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
else
{
ptr = LTG_SIGN(_j);
ALOOPBYTE(
union_r[i] |= ptr[i];
);
ALOOPBYTE
union_r[i] |= ptr[i];
}
*right++ = j;
v->spl_nright++;

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.18 2007/02/28 22:44:38 tgl Exp $ */
/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.19 2007/11/16 00:13:02 momjian Exp $ */
#ifndef __LTREE_H__
#define __LTREE_H__
@ -178,10 +178,8 @@ ltree *lca_inner(ltree ** a, int len);
typedef unsigned char BITVEC[SIGLEN];
typedef unsigned char *BITVECP;
#define LOOPBYTE(a) \
for(i=0;i<SIGLEN;i++) {\
a;\
}
#define LOOPBYTE \
for(i=0;i<SIGLEN;i++)
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
#define GETBITBYTE(x,i) ( ((unsigned char)(x)) >> i & 0x01 )
@ -235,10 +233,8 @@ typedef struct
#define ASIGLENBIT (ASIGLEN*BITBYTE)
typedef unsigned char ABITVEC[ASIGLEN];
#define ALOOPBYTE(a) \
for(i=0;i<ASIGLEN;i++) {\
a;\
}
#define ALOOPBYTE \
for(i=0;i<ASIGLEN;i++)
#define AHASHVAL(val) (((unsigned int)(val)) % ASIGLENBIT)
#define AHASH(sign, val) SETBIT((sign), AHASHVAL(val))

View File

@ -1,7 +1,7 @@
/*
* GiST support for ltree
* Teodor Sigaev <teodor@stack.net>
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.20 2007/02/28 22:44:38 tgl Exp $
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.21 2007/11/16 00:13:02 momjian Exp $
*/
#include "ltree.h"
@ -133,13 +133,16 @@ ltree_same(PG_FUNCTION_ARGS)
*result = true;
if (!LTG_ISALLTRUE(a))
LOOPBYTE(
if (sa[i] != sb[i])
{
*result = false;
break;
{
LOOPBYTE
{
if (sa[i] != sb[i])
{
*result = false;
break;
}
}
);
}
}
PG_RETURN_POINTER(result);
@ -198,9 +201,8 @@ ltree_union(PG_FUNCTION_ARGS)
{
BITVECP sc = LTG_SIGN(cur);
LOOPBYTE(
((unsigned char *) base)[i] |= sc[i];
);
LOOPBYTE
((unsigned char *) base)[i] |= sc[i];
}
curtree = LTG_LNODE(cur);
@ -215,13 +217,14 @@ ltree_union(PG_FUNCTION_ARGS)
if (isalltrue == false)
{
isalltrue = true;
LOOPBYTE(
if (((unsigned char *) base)[i] != 0xff)
{
isalltrue = false;
break;
LOOPBYTE
{
if (((unsigned char *) base)[i] != 0xff)
{
isalltrue = false;
break;
}
}
);
}
isleqr = (left == right || ISEQ(left, right)) ? true : false;
@ -343,9 +346,8 @@ ltree_picksplit(PG_FUNCTION_ARGS)
{
BITVECP sc = LTG_SIGN(lu);
LOOPBYTE(
((unsigned char *) ls)[i] |= sc[i];
);
LOOPBYTE
((unsigned char *) ls)[i] |= sc[i];
}
}
}
@ -365,9 +367,8 @@ ltree_picksplit(PG_FUNCTION_ARGS)
{
BITVECP sc = LTG_SIGN(lu);
LOOPBYTE(
((unsigned char *) rs)[i] |= sc[i];
);
LOOPBYTE
((unsigned char *) rs)[i] |= sc[i];
}
}
}
@ -376,25 +377,27 @@ ltree_picksplit(PG_FUNCTION_ARGS)
if (lisat == false)
{
lisat = true;
LOOPBYTE(
if (((unsigned char *) ls)[i] != 0xff)
{
lisat = false;
break;
LOOPBYTE
{
if (((unsigned char *) ls)[i] != 0xff)
{
lisat = false;
break;
}
}
);
}
if (risat == false)
{
risat = true;
LOOPBYTE(
if (((unsigned char *) rs)[i] != 0xff)
{
risat = false;
break;
LOOPBYTE
{
if (((unsigned char *) rs)[i] != 0xff)
{
risat = false;
break;
}
}
);
}
lu_l = LTG_GETLNODE(GETENTRY(entryvec, array[FirstOffsetNumber].index));