Commit 224f91f6 authored by Bruce Momjian's avatar Bruce Momjian

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.
parent 7d4c99b4
...@@ -16,15 +16,11 @@ typedef char *BITVECP; ...@@ -16,15 +16,11 @@ typedef char *BITVECP;
#define SIGPTR(x) ( (BITVECP) ARR_DATA_PTR(x) ) #define SIGPTR(x) ( (BITVECP) ARR_DATA_PTR(x) )
#define LOOPBYTE(a) \ #define LOOPBYTE \
for(i=0;i<SIGLEN;i++) {\ for(i=0;i<SIGLEN;i++)
a;\
}
#define LOOPBIT(a) \ #define LOOPBIT \
for(i=0;i<SIGLENBIT;i++) {\ for(i=0;i<SIGLENBIT;i++)
a;\
}
/* beware of multiple evaluation of arguments to these macros! */ /* beware of multiple evaluation of arguments to these macros! */
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
...@@ -148,10 +144,11 @@ ghstore_compress(PG_FUNCTION_ARGS) ...@@ -148,10 +144,11 @@ ghstore_compress(PG_FUNCTION_ARGS)
GISTTYPE *res; GISTTYPE *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
LOOPBYTE( LOOPBYTE
if ((sign[i] & 0xff) != 0xff) {
if ((sign[i] & 0xff) != 0xff)
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
); }
res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE)); res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE)); SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE));
...@@ -211,13 +208,14 @@ ghstore_same(PG_FUNCTION_ARGS) ...@@ -211,13 +208,14 @@ ghstore_same(PG_FUNCTION_ARGS)
sb = GETSIGN(b); sb = GETSIGN(b);
*result = true; *result = true;
LOOPBYTE( LOOPBYTE
if (sa[i] != sb[i]) {
{ if (sa[i] != sb[i])
*result = false; {
break; *result = false;
break;
}
} }
);
} }
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
...@@ -228,10 +226,11 @@ sizebitvec(BITVECP sign) ...@@ -228,10 +226,11 @@ sizebitvec(BITVECP sign)
int4 size = 0, int4 size = 0,
i; i;
LOOPBYTE( LOOPBYTE
size += SUMBIT(sign); {
sign = (BITVECP) (((char *) sign) + 1); size += SUMBIT(sign);
); sign = (BITVECP) (((char *) sign) + 1);
}
return size; return size;
} }
...@@ -241,10 +240,11 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -241,10 +240,11 @@ hemdistsign(BITVECP a, BITVECP b)
int i, int i,
dist = 0; dist = 0;
LOOPBIT( LOOPBIT
if (GETBIT(a, i) != GETBIT(b, i)) {
if (GETBIT(a, i) != GETBIT(b, i))
dist++; dist++;
); }
return dist; return dist;
} }
...@@ -272,9 +272,8 @@ unionkey(BITVECP sbase, GISTTYPE * add) ...@@ -272,9 +272,8 @@ unionkey(BITVECP sbase, GISTTYPE * add)
if (ISALLTRUE(add)) if (ISALLTRUE(add))
return 1; return 1;
LOOPBYTE( LOOPBYTE
sbase[i] |= sadd[i]; sbase[i] |= sadd[i];
);
return 0; return 0;
} }
...@@ -470,9 +469,8 @@ ghstore_picksplit(PG_FUNCTION_ARGS) ...@@ -470,9 +469,8 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = GETSIGN(_j); ptr = GETSIGN(_j);
LOOPBYTE( LOOPBYTE
union_l[i] |= ptr[i]; union_l[i] |= ptr[i];
);
} }
*left++ = j; *left++ = j;
v->spl_nleft++; v->spl_nleft++;
...@@ -487,9 +485,8 @@ ghstore_picksplit(PG_FUNCTION_ARGS) ...@@ -487,9 +485,8 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = GETSIGN(_j); ptr = GETSIGN(_j);
LOOPBYTE( LOOPBYTE
union_r[i] |= ptr[i]; union_r[i] |= ptr[i];
);
} }
*right++ = j; *right++ = j;
v->spl_nright++; v->spl_nright++;
......
...@@ -66,10 +66,8 @@ ...@@ -66,10 +66,8 @@
typedef char BITVEC[SIGLEN]; typedef char BITVEC[SIGLEN];
typedef char *BITVECP; typedef char *BITVECP;
#define LOOPBYTE(a) \ #define LOOPBYTE \
for(i=0;i<SIGLEN;i++) {\ for(i=0;i<SIGLEN;i++)
a;\
}
/* beware of multiple evaluation of arguments to these macros! */ /* beware of multiple evaluation of arguments to these macros! */
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )
......
...@@ -125,13 +125,14 @@ g_intbig_same(PG_FUNCTION_ARGS) ...@@ -125,13 +125,14 @@ g_intbig_same(PG_FUNCTION_ARGS)
sb = GETSIGN(b); sb = GETSIGN(b);
*result = true; *result = true;
LOOPBYTE( LOOPBYTE
if (sa[i] != sb[i]) {
{ if (sa[i] != sb[i])
*result = false; {
break; *result = false;
break;
}
} }
);
} }
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
...@@ -185,10 +186,11 @@ g_intbig_compress(PG_FUNCTION_ARGS) ...@@ -185,10 +186,11 @@ g_intbig_compress(PG_FUNCTION_ARGS)
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
GISTTYPE *res; GISTTYPE *res;
LOOPBYTE( LOOPBYTE
if ((sign[i] & 0xff) != 0xff) {
PG_RETURN_POINTER(entry); if ((sign[i] & 0xff) != 0xff)
); PG_RETURN_POINTER(entry);
}
res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE)); res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE)); SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE));
...@@ -212,9 +214,8 @@ sizebitvec(BITVECP sign) ...@@ -212,9 +214,8 @@ sizebitvec(BITVECP sign)
int4 size = 0, int4 size = 0,
i; i;
LOOPBYTE( LOOPBYTE
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
);
return size; return size;
} }
...@@ -225,10 +226,11 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -225,10 +226,11 @@ hemdistsign(BITVECP a, BITVECP b)
diff, diff,
dist = 0; dist = 0;
LOOPBYTE( LOOPBYTE
diff = (unsigned char) (a[i] ^ b[i]); {
dist += number_of_ones[diff]; diff = (unsigned char) (a[i] ^ b[i]);
); dist += number_of_ones[diff];
}
return dist; return dist;
} }
...@@ -262,9 +264,8 @@ unionkey(BITVECP sbase, GISTTYPE * add) ...@@ -262,9 +264,8 @@ unionkey(BITVECP sbase, GISTTYPE * add)
if (ISALLTRUE(add)) if (ISALLTRUE(add))
return 1; return 1;
LOOPBYTE( LOOPBYTE
sbase[i] |= sadd[i]; sbase[i] |= sadd[i];
);
return 0; return 0;
} }
...@@ -458,9 +459,8 @@ g_intbig_picksplit(PG_FUNCTION_ARGS) ...@@ -458,9 +459,8 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = GETSIGN(_j); ptr = GETSIGN(_j);
LOOPBYTE( LOOPBYTE
union_l[i] |= ptr[i]; union_l[i] |= ptr[i];
);
} }
*left++ = j; *left++ = j;
v->spl_nleft++; v->spl_nleft++;
...@@ -475,9 +475,8 @@ g_intbig_picksplit(PG_FUNCTION_ARGS) ...@@ -475,9 +475,8 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = GETSIGN(_j); ptr = GETSIGN(_j);
LOOPBYTE( LOOPBYTE
union_r[i] |= ptr[i]; union_r[i] |= ptr[i];
);
} }
*right++ = j; *right++ = j;
v->spl_nright++; v->spl_nright++;
...@@ -548,13 +547,14 @@ g_intbig_consistent(PG_FUNCTION_ARGS) ...@@ -548,13 +547,14 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
de = GETSIGN((GISTTYPE *) DatumGetPointer(entry->key)); de = GETSIGN((GISTTYPE *) DatumGetPointer(entry->key));
dq = qp; dq = qp;
retval = true; retval = true;
LOOPBYTE( LOOPBYTE
if (de[i] != dq[i]) {
{ if (de[i] != dq[i])
retval = false; {
break; retval = false;
break;
}
} }
);
} }
else else
...@@ -588,14 +588,14 @@ g_intbig_consistent(PG_FUNCTION_ARGS) ...@@ -588,14 +588,14 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
de = GETSIGN((GISTTYPE *) DatumGetPointer(entry->key)); de = GETSIGN((GISTTYPE *) DatumGetPointer(entry->key));
dq = qp; dq = qp;
retval = true; retval = true;
LOOPBYTE( LOOPBYTE
if (de[i] & ~dq[i]) {
{ if (de[i] & ~dq[i])
retval = false; {
break; retval = false;
break;
}
} }
);
} }
else else
retval = _intbig_overlap((GISTTYPE *) DatumGetPointer(entry->key), query); retval = _intbig_overlap((GISTTYPE *) DatumGetPointer(entry->key), query);
......
...@@ -118,10 +118,11 @@ _ltree_compress(PG_FUNCTION_ARGS) ...@@ -118,10 +118,11 @@ _ltree_compress(PG_FUNCTION_ARGS)
BITVECP sign = LTG_SIGN(DatumGetPointer(entry->key)); BITVECP sign = LTG_SIGN(DatumGetPointer(entry->key));
ALOOPBYTE( ALOOPBYTE
if ((sign[i] & 0xff) != 0xff) {
PG_RETURN_POINTER(retval); if ((sign[i] & 0xff) != 0xff)
); PG_RETURN_POINTER(retval);
}
len = LTG_HDRSIZE; len = LTG_HDRSIZE;
key = (ltree_gist *) palloc(len); key = (ltree_gist *) palloc(len);
SET_VARSIZE(key, len); SET_VARSIZE(key, len);
...@@ -155,13 +156,14 @@ _ltree_same(PG_FUNCTION_ARGS) ...@@ -155,13 +156,14 @@ _ltree_same(PG_FUNCTION_ARGS)
sb = LTG_SIGN(b); sb = LTG_SIGN(b);
*result = true; *result = true;
ALOOPBYTE( ALOOPBYTE
if (sa[i] != sb[i]) {
{ if (sa[i] != sb[i])
*result = false; {
break; *result = false;
break;
}
} }
);
} }
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
...@@ -175,9 +177,8 @@ unionkey(BITVECP sbase, ltree_gist * add) ...@@ -175,9 +177,8 @@ unionkey(BITVECP sbase, ltree_gist * add)
if (LTG_ISALLTRUE(add)) if (LTG_ISALLTRUE(add))
return 1; return 1;
ALOOPBYTE( ALOOPBYTE
sbase[i] |= sadd[i]; sbase[i] |= sadd[i];
);
return 0; return 0;
} }
...@@ -219,9 +220,8 @@ sizebitvec(BITVECP sign) ...@@ -219,9 +220,8 @@ sizebitvec(BITVECP sign)
int4 size = 0, int4 size = 0,
i; i;
ALOOPBYTE( ALOOPBYTE
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
);
return size; return size;
} }
...@@ -232,10 +232,11 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -232,10 +232,11 @@ hemdistsign(BITVECP a, BITVECP b)
diff, diff,
dist = 0; dist = 0;
ALOOPBYTE( ALOOPBYTE
diff = (unsigned char) (a[i] ^ b[i]); {
dist += number_of_ones[diff]; diff = (unsigned char) (a[i] ^ b[i]);
); dist += number_of_ones[diff];
}
return dist; return dist;
} }
...@@ -410,9 +411,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS) ...@@ -410,9 +411,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = LTG_SIGN(_j); ptr = LTG_SIGN(_j);
ALOOPBYTE( ALOOPBYTE
union_l[i] |= ptr[i]; union_l[i] |= ptr[i];
);
} }
*left++ = j; *left++ = j;
v->spl_nleft++; v->spl_nleft++;
...@@ -427,9 +427,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS) ...@@ -427,9 +427,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = LTG_SIGN(_j); ptr = LTG_SIGN(_j);
ALOOPBYTE( ALOOPBYTE
union_r[i] |= ptr[i]; union_r[i] |= ptr[i];
);
} }
*right++ = j; *right++ = j;
v->spl_nright++; v->spl_nright++;
......
/* $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__ #ifndef __LTREE_H__
#define __LTREE_H__ #define __LTREE_H__
...@@ -178,10 +178,8 @@ ltree *lca_inner(ltree ** a, int len); ...@@ -178,10 +178,8 @@ ltree *lca_inner(ltree ** a, int len);
typedef unsigned char BITVEC[SIGLEN]; typedef unsigned char BITVEC[SIGLEN];
typedef unsigned char *BITVECP; typedef unsigned char *BITVECP;
#define LOOPBYTE(a) \ #define LOOPBYTE \
for(i=0;i<SIGLEN;i++) {\ for(i=0;i<SIGLEN;i++)
a;\
}
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
#define GETBITBYTE(x,i) ( ((unsigned char)(x)) >> i & 0x01 ) #define GETBITBYTE(x,i) ( ((unsigned char)(x)) >> i & 0x01 )
...@@ -235,10 +233,8 @@ typedef struct ...@@ -235,10 +233,8 @@ typedef struct
#define ASIGLENBIT (ASIGLEN*BITBYTE) #define ASIGLENBIT (ASIGLEN*BITBYTE)
typedef unsigned char ABITVEC[ASIGLEN]; typedef unsigned char ABITVEC[ASIGLEN];
#define ALOOPBYTE(a) \ #define ALOOPBYTE \
for(i=0;i<ASIGLEN;i++) {\ for(i=0;i<ASIGLEN;i++)
a;\
}
#define AHASHVAL(val) (((unsigned int)(val)) % ASIGLENBIT) #define AHASHVAL(val) (((unsigned int)(val)) % ASIGLENBIT)
#define AHASH(sign, val) SETBIT((sign), AHASHVAL(val)) #define AHASH(sign, val) SETBIT((sign), AHASHVAL(val))
......
/* /*
* GiST support for ltree * GiST support for ltree
* Teodor Sigaev <teodor@stack.net> * 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" #include "ltree.h"
...@@ -133,13 +133,16 @@ ltree_same(PG_FUNCTION_ARGS) ...@@ -133,13 +133,16 @@ ltree_same(PG_FUNCTION_ARGS)
*result = true; *result = true;
if (!LTG_ISALLTRUE(a)) if (!LTG_ISALLTRUE(a))
LOOPBYTE( {
if (sa[i] != sb[i]) LOOPBYTE
{ {
*result = false; if (sa[i] != sb[i])
break; {
*result = false;
break;
}
} }
); }
} }
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
...@@ -198,9 +201,8 @@ ltree_union(PG_FUNCTION_ARGS) ...@@ -198,9 +201,8 @@ ltree_union(PG_FUNCTION_ARGS)
{ {
BITVECP sc = LTG_SIGN(cur); BITVECP sc = LTG_SIGN(cur);
LOOPBYTE( LOOPBYTE
((unsigned char *) base)[i] |= sc[i]; ((unsigned char *) base)[i] |= sc[i];
);
} }
curtree = LTG_LNODE(cur); curtree = LTG_LNODE(cur);
...@@ -215,13 +217,14 @@ ltree_union(PG_FUNCTION_ARGS) ...@@ -215,13 +217,14 @@ ltree_union(PG_FUNCTION_ARGS)
if (isalltrue == false) if (isalltrue == false)
{ {
isalltrue = true; isalltrue = true;
LOOPBYTE( LOOPBYTE
if (((unsigned char *) base)[i] != 0xff) {
{ if (((unsigned char *) base)[i] != 0xff)
isalltrue = false; {
break; isalltrue = false;
break;
}
} }
);
} }
isleqr = (left == right || ISEQ(left, right)) ? true : false; isleqr = (left == right || ISEQ(left, right)) ? true : false;
...@@ -343,9 +346,8 @@ ltree_picksplit(PG_FUNCTION_ARGS) ...@@ -343,9 +346,8 @@ ltree_picksplit(PG_FUNCTION_ARGS)
{ {
BITVECP sc = LTG_SIGN(lu); BITVECP sc = LTG_SIGN(lu);
LOOPBYTE( LOOPBYTE
((unsigned char *) ls)[i] |= sc[i]; ((unsigned char *) ls)[i] |= sc[i];
);
} }
} }
} }
...@@ -365,9 +367,8 @@ ltree_picksplit(PG_FUNCTION_ARGS) ...@@ -365,9 +367,8 @@ ltree_picksplit(PG_FUNCTION_ARGS)
{ {
BITVECP sc = LTG_SIGN(lu); BITVECP sc = LTG_SIGN(lu);
LOOPBYTE( LOOPBYTE
((unsigned char *) rs)[i] |= sc[i]; ((unsigned char *) rs)[i] |= sc[i];
);
} }
} }
} }
...@@ -376,25 +377,27 @@ ltree_picksplit(PG_FUNCTION_ARGS) ...@@ -376,25 +377,27 @@ ltree_picksplit(PG_FUNCTION_ARGS)
if (lisat == false) if (lisat == false)
{ {
lisat = true; lisat = true;
LOOPBYTE( LOOPBYTE
if (((unsigned char *) ls)[i] != 0xff) {
{ if (((unsigned char *) ls)[i] != 0xff)
lisat = false; {
break; lisat = false;
break;
}
} }
);
} }
if (risat == false) if (risat == false)
{ {
risat = true; risat = true;
LOOPBYTE( LOOPBYTE
if (((unsigned char *) rs)[i] != 0xff) {
{ if (((unsigned char *) rs)[i] != 0xff)
risat = false; {
break; risat = false;
break;
}
} }
);
} }
lu_l = LTG_GETLNODE(GETENTRY(entryvec, array[FirstOffsetNumber].index)); lu_l = LTG_GETLNODE(GETENTRY(entryvec, array[FirstOffsetNumber].index));
......
...@@ -49,10 +49,8 @@ typedef struct ...@@ -49,10 +49,8 @@ typedef struct
typedef char BITVEC[SIGLEN]; typedef char BITVEC[SIGLEN];
typedef char *BITVECP; typedef char *BITVECP;
#define LOOPBYTE(a) \ #define LOOPBYTE \
for(i=0;i<SIGLEN;i++) {\ for(i=0;i<SIGLEN;i++)
a;\
}
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
#define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 ) #define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 )
......
...@@ -113,10 +113,11 @@ gtrgm_compress(PG_FUNCTION_ARGS) ...@@ -113,10 +113,11 @@ gtrgm_compress(PG_FUNCTION_ARGS)
TRGM *res; TRGM *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
LOOPBYTE( LOOPBYTE
if ((sign[i] & 0xff) != 0xff) {
if ((sign[i] & 0xff) != 0xff)
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
); }
len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0); len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0);
res = (TRGM *) palloc(len); res = (TRGM *) palloc(len);
...@@ -210,9 +211,8 @@ unionkey(BITVECP sbase, TRGM * add) ...@@ -210,9 +211,8 @@ unionkey(BITVECP sbase, TRGM * add)
if (ISALLTRUE(add)) if (ISALLTRUE(add))
return 1; return 1;
LOOPBYTE( LOOPBYTE
sbase[i] |= sadd[i]; sbase[i] |= sadd[i];
);
} }
else else
{ {
...@@ -284,13 +284,14 @@ gtrgm_same(PG_FUNCTION_ARGS) ...@@ -284,13 +284,14 @@ gtrgm_same(PG_FUNCTION_ARGS)
sb = GETSIGN(b); sb = GETSIGN(b);
*result = true; *result = true;
LOOPBYTE( LOOPBYTE
if (sa[i] != sb[i]) {
{ if (sa[i] != sb[i])
*result = false; {
break; *result = false;
break;
}
} }
);
} }
} }
else else
...@@ -325,9 +326,8 @@ sizebitvec(BITVECP sign) ...@@ -325,9 +326,8 @@ sizebitvec(BITVECP sign)
int4 size = 0, int4 size = 0,
i; i;
LOOPBYTE( LOOPBYTE
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
);
return size; return size;
} }
...@@ -338,10 +338,11 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -338,10 +338,11 @@ hemdistsign(BITVECP a, BITVECP b)
diff, diff,
dist = 0; dist = 0;
LOOPBYTE( LOOPBYTE
diff = (unsigned char) (a[i] ^ b[i]); {
dist += number_of_ones[diff]; diff = (unsigned char) (a[i] ^ b[i]);
); dist += number_of_ones[diff];
}
return dist; return dist;
} }
...@@ -594,9 +595,8 @@ gtrgm_picksplit(PG_FUNCTION_ARGS) ...@@ -594,9 +595,8 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = cache[j].sign; ptr = cache[j].sign;
LOOPBYTE( LOOPBYTE
union_l[i] |= ptr[i]; union_l[i] |= ptr[i];
);
} }
*left++ = j; *left++ = j;
v->spl_nleft++; v->spl_nleft++;
...@@ -611,9 +611,8 @@ gtrgm_picksplit(PG_FUNCTION_ARGS) ...@@ -611,9 +611,8 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = cache[j].sign; ptr = cache[j].sign;
LOOPBYTE( LOOPBYTE
union_r[i] |= ptr[i]; union_r[i] |= ptr[i];
);
} }
*right++ = j; *right++ = j;
v->spl_nright++; v->spl_nright++;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.4 2007/09/11 08:46:29 teodor Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.5 2007/11/16 00:13:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -30,10 +30,8 @@ ...@@ -30,10 +30,8 @@
typedef char BITVEC[SIGLEN]; typedef char BITVEC[SIGLEN];
typedef char *BITVECP; typedef char *BITVECP;
#define LOOPBYTE(a) \ #define LOOPBYTE \
for(i=0;i<SIGLEN;i++) {\ for(i=0;i<SIGLEN;i++)
a;\
}
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) ) #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )
#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 ) #define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 )
...@@ -252,10 +250,11 @@ gtsvector_compress(PG_FUNCTION_ARGS) ...@@ -252,10 +250,11 @@ gtsvector_compress(PG_FUNCTION_ARGS)
SignTSVector *res; SignTSVector *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
LOOPBYTE( LOOPBYTE
if ((sign[i] & 0xff) != 0xff) {
if ((sign[i] & 0xff) != 0xff)
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
); }
len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0); len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0);
res = (SignTSVector *) palloc(len); res = (SignTSVector *) palloc(len);
...@@ -376,9 +375,8 @@ unionkey(BITVECP sbase, SignTSVector * add) ...@@ -376,9 +375,8 @@ unionkey(BITVECP sbase, SignTSVector * add)
if (ISALLTRUE(add)) if (ISALLTRUE(add))
return 1; return 1;
LOOPBYTE( LOOPBYTE
sbase[i] |= sadd[i]; sbase[i] |= sadd[i];
);
} }
else else
{ {
...@@ -446,13 +444,14 @@ gtsvector_same(PG_FUNCTION_ARGS) ...@@ -446,13 +444,14 @@ gtsvector_same(PG_FUNCTION_ARGS)
sb = GETSIGN(b); sb = GETSIGN(b);
*result = true; *result = true;
LOOPBYTE( LOOPBYTE
if (sa[i] != sb[i]) {
{ if (sa[i] != sb[i])
*result = false; {
break; *result = false;
break;
}
} }
);
} }
} }
else else
...@@ -487,9 +486,8 @@ sizebitvec(BITVECP sign) ...@@ -487,9 +486,8 @@ sizebitvec(BITVECP sign)
int4 size = 0, int4 size = 0,
i; i;
LOOPBYTE( LOOPBYTE
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
);
return size; return size;
} }
...@@ -500,10 +498,11 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -500,10 +498,11 @@ hemdistsign(BITVECP a, BITVECP b)
diff, diff,
dist = 0; dist = 0;
LOOPBYTE( LOOPBYTE
diff = (unsigned char) (a[i] ^ b[i]); {
dist += number_of_ones[diff]; diff = (unsigned char) (a[i] ^ b[i]);
); dist += number_of_ones[diff];
}
return dist; return dist;
} }
...@@ -760,9 +759,8 @@ gtsvector_picksplit(PG_FUNCTION_ARGS) ...@@ -760,9 +759,8 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = cache[j].sign; ptr = cache[j].sign;
LOOPBYTE( LOOPBYTE
union_l[i] |= ptr[i]; union_l[i] |= ptr[i];
);
} }
*left++ = j; *left++ = j;
v->spl_nleft++; v->spl_nleft++;
...@@ -777,9 +775,8 @@ gtsvector_picksplit(PG_FUNCTION_ARGS) ...@@ -777,9 +775,8 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
else else
{ {
ptr = cache[j].sign; ptr = cache[j].sign;
LOOPBYTE( LOOPBYTE
union_r[i] |= ptr[i]; union_r[i] |= ptr[i];
);
} }
*right++ = j; *right++ = j;
v->spl_nright++; v->spl_nright++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment