Skip to content

Commit 224f91f

Browse files
committed
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.
1 parent 7d4c99b commit 224f91f

File tree

9 files changed

+191
-204
lines changed

9 files changed

+191
-204
lines changed

contrib/hstore/hstore_gist.c

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ typedef char *BITVECP;
1616
#define SIGPTR(x) ( (BITVECP) ARR_DATA_PTR(x) )
1717

1818

19-
#define LOOPBYTE(a) \
20-
for(i=0;i<SIGLEN;i++) {\
21-
a;\
22-
}
19+
#define LOOPBYTE \
20+
for(i=0;i<SIGLEN;i++)
2321

24-
#define LOOPBIT(a) \
25-
for(i=0;i<SIGLENBIT;i++) {\
26-
a;\
27-
}
22+
#define LOOPBIT \
23+
for(i=0;i<SIGLENBIT;i++)
2824

2925
/* beware of multiple evaluation of arguments to these macros! */
3026
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
@@ -148,10 +144,11 @@ ghstore_compress(PG_FUNCTION_ARGS)
148144
GISTTYPE *res;
149145
BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
150146

151-
LOOPBYTE(
152-
if ((sign[i] & 0xff) != 0xff)
147+
LOOPBYTE
148+
{
149+
if ((sign[i] & 0xff) != 0xff)
153150
PG_RETURN_POINTER(retval);
154-
);
151+
}
155152

156153
res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
157154
SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE));
@@ -211,13 +208,14 @@ ghstore_same(PG_FUNCTION_ARGS)
211208
sb = GETSIGN(b);
212209

213210
*result = true;
214-
LOOPBYTE(
215-
if (sa[i] != sb[i])
216-
{
217-
*result = false;
218-
break;
211+
LOOPBYTE
212+
{
213+
if (sa[i] != sb[i])
214+
{
215+
*result = false;
216+
break;
217+
}
219218
}
220-
);
221219
}
222220
PG_RETURN_POINTER(result);
223221
}
@@ -228,10 +226,11 @@ sizebitvec(BITVECP sign)
228226
int4 size = 0,
229227
i;
230228

231-
LOOPBYTE(
232-
size += SUMBIT(sign);
233-
sign = (BITVECP) (((char *) sign) + 1);
234-
);
229+
LOOPBYTE
230+
{
231+
size += SUMBIT(sign);
232+
sign = (BITVECP) (((char *) sign) + 1);
233+
}
235234
return size;
236235
}
237236

@@ -241,10 +240,11 @@ hemdistsign(BITVECP a, BITVECP b)
241240
int i,
242241
dist = 0;
243242

244-
LOOPBIT(
245-
if (GETBIT(a, i) != GETBIT(b, i))
243+
LOOPBIT
244+
{
245+
if (GETBIT(a, i) != GETBIT(b, i))
246246
dist++;
247-
);
247+
}
248248
return dist;
249249
}
250250

@@ -272,9 +272,8 @@ unionkey(BITVECP sbase, GISTTYPE * add)
272272

273273
if (ISALLTRUE(add))
274274
return 1;
275-
LOOPBYTE(
276-
sbase[i] |= sadd[i];
277-
);
275+
LOOPBYTE
276+
sbase[i] |= sadd[i];
278277
return 0;
279278
}
280279

@@ -470,9 +469,8 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
470469
else
471470
{
472471
ptr = GETSIGN(_j);
473-
LOOPBYTE(
474-
union_l[i] |= ptr[i];
475-
);
472+
LOOPBYTE
473+
union_l[i] |= ptr[i];
476474
}
477475
*left++ = j;
478476
v->spl_nleft++;
@@ -487,9 +485,8 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
487485
else
488486
{
489487
ptr = GETSIGN(_j);
490-
LOOPBYTE(
491-
union_r[i] |= ptr[i];
492-
);
488+
LOOPBYTE
489+
union_r[i] |= ptr[i];
493490
}
494491
*right++ = j;
495492
v->spl_nright++;

contrib/intarray/_int.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@
6666
typedef char BITVEC[SIGLEN];
6767
typedef char *BITVECP;
6868

69-
#define LOOPBYTE(a) \
70-
for(i=0;i<SIGLEN;i++) {\
71-
a;\
72-
}
69+
#define LOOPBYTE \
70+
for(i=0;i<SIGLEN;i++)
7371

7472
/* beware of multiple evaluation of arguments to these macros! */
7573
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )

contrib/intarray/_intbig_gist.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ g_intbig_same(PG_FUNCTION_ARGS)
125125
sb = GETSIGN(b);
126126

127127
*result = true;
128-
LOOPBYTE(
129-
if (sa[i] != sb[i])
130-
{
131-
*result = false;
132-
break;
128+
LOOPBYTE
129+
{
130+
if (sa[i] != sb[i])
131+
{
132+
*result = false;
133+
break;
134+
}
133135
}
134-
);
135136
}
136137
PG_RETURN_POINTER(result);
137138
}
@@ -185,10 +186,11 @@ g_intbig_compress(PG_FUNCTION_ARGS)
185186
BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
186187
GISTTYPE *res;
187188

188-
LOOPBYTE(
189-
if ((sign[i] & 0xff) != 0xff)
190-
PG_RETURN_POINTER(entry);
191-
);
189+
LOOPBYTE
190+
{
191+
if ((sign[i] & 0xff) != 0xff)
192+
PG_RETURN_POINTER(entry);
193+
}
192194

193195
res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
194196
SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE));
@@ -212,9 +214,8 @@ sizebitvec(BITVECP sign)
212214
int4 size = 0,
213215
i;
214216

215-
LOOPBYTE(
216-
size += number_of_ones[(unsigned char) sign[i]];
217-
);
217+
LOOPBYTE
218+
size += number_of_ones[(unsigned char) sign[i]];
218219
return size;
219220
}
220221

@@ -225,10 +226,11 @@ hemdistsign(BITVECP a, BITVECP b)
225226
diff,
226227
dist = 0;
227228

228-
LOOPBYTE(
229-
diff = (unsigned char) (a[i] ^ b[i]);
230-
dist += number_of_ones[diff];
231-
);
229+
LOOPBYTE
230+
{
231+
diff = (unsigned char) (a[i] ^ b[i]);
232+
dist += number_of_ones[diff];
233+
}
232234
return dist;
233235
}
234236

@@ -262,9 +264,8 @@ unionkey(BITVECP sbase, GISTTYPE * add)
262264

263265
if (ISALLTRUE(add))
264266
return 1;
265-
LOOPBYTE(
266-
sbase[i] |= sadd[i];
267-
);
267+
LOOPBYTE
268+
sbase[i] |= sadd[i];
268269
return 0;
269270
}
270271

@@ -458,9 +459,8 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
458459
else
459460
{
460461
ptr = GETSIGN(_j);
461-
LOOPBYTE(
462-
union_l[i] |= ptr[i];
463-
);
462+
LOOPBYTE
463+
union_l[i] |= ptr[i];
464464
}
465465
*left++ = j;
466466
v->spl_nleft++;
@@ -475,9 +475,8 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
475475
else
476476
{
477477
ptr = GETSIGN(_j);
478-
LOOPBYTE(
479-
union_r[i] |= ptr[i];
480-
);
478+
LOOPBYTE
479+
union_r[i] |= ptr[i];
481480
}
482481
*right++ = j;
483482
v->spl_nright++;
@@ -548,13 +547,14 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
548547
de = GETSIGN((GISTTYPE *) DatumGetPointer(entry->key));
549548
dq = qp;
550549
retval = true;
551-
LOOPBYTE(
552-
if (de[i] != dq[i])
553-
{
554-
retval = false;
555-
break;
550+
LOOPBYTE
551+
{
552+
if (de[i] != dq[i])
553+
{
554+
retval = false;
555+
break;
556+
}
556557
}
557-
);
558558

559559
}
560560
else
@@ -588,14 +588,14 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
588588
de = GETSIGN((GISTTYPE *) DatumGetPointer(entry->key));
589589
dq = qp;
590590
retval = true;
591-
LOOPBYTE(
592-
if (de[i] & ~dq[i])
593-
{
594-
retval = false;
595-
break;
591+
LOOPBYTE
592+
{
593+
if (de[i] & ~dq[i])
594+
{
595+
retval = false;
596+
break;
597+
}
596598
}
597-
);
598-
599599
}
600600
else
601601
retval = _intbig_overlap((GISTTYPE *) DatumGetPointer(entry->key), query);

contrib/ltree/_ltree_gist.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ _ltree_compress(PG_FUNCTION_ARGS)
118118

119119
BITVECP sign = LTG_SIGN(DatumGetPointer(entry->key));
120120

121-
ALOOPBYTE(
122-
if ((sign[i] & 0xff) != 0xff)
123-
PG_RETURN_POINTER(retval);
124-
);
121+
ALOOPBYTE
122+
{
123+
if ((sign[i] & 0xff) != 0xff)
124+
PG_RETURN_POINTER(retval);
125+
}
125126
len = LTG_HDRSIZE;
126127
key = (ltree_gist *) palloc(len);
127128
SET_VARSIZE(key, len);
@@ -155,13 +156,14 @@ _ltree_same(PG_FUNCTION_ARGS)
155156
sb = LTG_SIGN(b);
156157

157158
*result = true;
158-
ALOOPBYTE(
159-
if (sa[i] != sb[i])
160-
{
161-
*result = false;
162-
break;
159+
ALOOPBYTE
160+
{
161+
if (sa[i] != sb[i])
162+
{
163+
*result = false;
164+
break;
165+
}
163166
}
164-
);
165167
}
166168
PG_RETURN_POINTER(result);
167169
}
@@ -175,9 +177,8 @@ unionkey(BITVECP sbase, ltree_gist * add)
175177
if (LTG_ISALLTRUE(add))
176178
return 1;
177179

178-
ALOOPBYTE(
179-
sbase[i] |= sadd[i];
180-
);
180+
ALOOPBYTE
181+
sbase[i] |= sadd[i];
181182
return 0;
182183
}
183184

@@ -219,9 +220,8 @@ sizebitvec(BITVECP sign)
219220
int4 size = 0,
220221
i;
221222

222-
ALOOPBYTE(
223-
size += number_of_ones[(unsigned char) sign[i]];
224-
);
223+
ALOOPBYTE
224+
size += number_of_ones[(unsigned char) sign[i]];
225225
return size;
226226
}
227227

@@ -232,10 +232,11 @@ hemdistsign(BITVECP a, BITVECP b)
232232
diff,
233233
dist = 0;
234234

235-
ALOOPBYTE(
236-
diff = (unsigned char) (a[i] ^ b[i]);
237-
dist += number_of_ones[diff];
238-
);
235+
ALOOPBYTE
236+
{
237+
diff = (unsigned char) (a[i] ^ b[i]);
238+
dist += number_of_ones[diff];
239+
}
239240
return dist;
240241
}
241242

@@ -410,9 +411,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
410411
else
411412
{
412413
ptr = LTG_SIGN(_j);
413-
ALOOPBYTE(
414-
union_l[i] |= ptr[i];
415-
);
414+
ALOOPBYTE
415+
union_l[i] |= ptr[i];
416416
}
417417
*left++ = j;
418418
v->spl_nleft++;
@@ -427,9 +427,8 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
427427
else
428428
{
429429
ptr = LTG_SIGN(_j);
430-
ALOOPBYTE(
431-
union_r[i] |= ptr[i];
432-
);
430+
ALOOPBYTE
431+
union_r[i] |= ptr[i];
433432
}
434433
*right++ = j;
435434
v->spl_nright++;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy