Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd0625c

Browse files
committed
Clean up some code using "(expr) ? true : false"
All the code paths simplified here were already using a boolean or used an expression that led to zero or one, making the extra bits unnecessary. Author: Justin Pryzby Reviewed-by: Tom Lane, Michael Paquier, Peter Smith Discussion: https://postgr.es/m/[email protected]
1 parent d6c916f commit fd0625c

File tree

22 files changed

+25
-25
lines changed

22 files changed

+25
-25
lines changed

contrib/intarray/_int_tool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ inner_int_contains(ArrayType *a, ArrayType *b)
4141
break; /* db[j] is not in da */
4242
}
4343

44-
return (n == nb) ? true : false;
44+
return (n == nb);
4545
}
4646

4747
/* arguments are assumed sorted */

contrib/ltree/ltree_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ ltree_same(PG_FUNCTION_ARGS)
137137
PG_RETURN_POINTER(result);
138138

139139
if (LTG_ISONENODE(a))
140-
*result = (ISEQ(LTG_NODE(a), LTG_NODE(b))) ? true : false;
140+
*result = ISEQ(LTG_NODE(a), LTG_NODE(b));
141141
else
142142
{
143143
int32 i;

contrib/sepgsql/selinux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static int sepgsql_mode = SEPGSQL_MODE_INTERNAL;
615615
bool
616616
sepgsql_is_enabled(void)
617617
{
618-
return (sepgsql_mode != SEPGSQL_MODE_DISABLED ? true : false);
618+
return (sepgsql_mode != SEPGSQL_MODE_DISABLED);
619619
}
620620

621621
/*

src/backend/access/gin/gindatapage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ dataIsMoveRight(GinBtree btree, Page page)
241241
if (GinPageIsDeleted(page))
242242
return true;
243243

244-
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0) ? true : false;
244+
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0);
245245
}
246246

247247
/*

src/backend/access/gin/ginutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ initGinState(GinState *state, Relation index)
100100
MemSet(state, 0, sizeof(GinState));
101101

102102
state->index = index;
103-
state->oneCol = (origTupdesc->natts == 1) ? true : false;
103+
state->oneCol = (origTupdesc->natts == 1);
104104
state->origTupdesc = origTupdesc;
105105

106106
for (i = 0; i < origTupdesc->natts; i++)

src/backend/access/gist/gistsplit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ supportSecondarySplit(Relation r, GISTSTATE *giststate, int attno,
303303
penalty2 = gistpenalty(giststate, attno, entry1, false, &entrySR, false);
304304

305305
if (penalty1 < penalty2)
306-
leaveOnLeft = (sv->spl_ldatum_exists) ? true : false;
306+
leaveOnLeft = sv->spl_ldatum_exists;
307307
else
308-
leaveOnLeft = (sv->spl_rdatum_exists) ? true : false;
308+
leaveOnLeft = sv->spl_rdatum_exists;
309309
}
310310

311311
if (leaveOnLeft == false)

src/backend/access/hash/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
816816
XLogRecPtr recptr;
817817

818818
xlrec.clear_dead_marking = clear_dead_marking;
819-
xlrec.is_primary_bucket_page = (buf == bucket_buf) ? true : false;
819+
xlrec.is_primary_bucket_page = (buf == bucket_buf);
820820

821821
XLogBeginInsert();
822822
XLogRegisterData((char *) &xlrec, SizeOfHashDelete);

src/backend/access/hash/hashinsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel)
176176
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
177177

178178
/* chain to a new overflow page */
179-
buf = _hash_addovflpage(rel, metabuf, buf, (buf == bucket_buf) ? true : false);
179+
buf = _hash_addovflpage(rel, metabuf, buf, (buf == bucket_buf));
180180
page = BufferGetPage(buf);
181181

182182
/* should fit now, given test above */

src/backend/access/hash/hashovfl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ _hash_squeezebucket(Relation rel,
953953
xl_hash_move_page_contents xlrec;
954954

955955
xlrec.ntups = nitups;
956-
xlrec.is_prim_bucket_same_wrt = (wbuf == bucket_buf) ? true : false;
956+
xlrec.is_prim_bucket_same_wrt = (wbuf == bucket_buf);
957957

958958
XLogBeginInsert();
959959
XLogRegisterData((char *) &xlrec, SizeOfHashMovePageContents);

src/backend/access/hash/hashpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ _hash_splitbucket(Relation rel,
11951195
all_tups_size = 0;
11961196

11971197
/* chain to a new overflow page */
1198-
nbuf = _hash_addovflpage(rel, metabuf, nbuf, (nbuf == bucket_nbuf) ? true : false);
1198+
nbuf = _hash_addovflpage(rel, metabuf, nbuf, (nbuf == bucket_nbuf));
11991199
npage = BufferGetPage(nbuf);
12001200
nopaque = (HashPageOpaque) PageGetSpecialPointer(npage);
12011201
}

0 commit comments

Comments
 (0)