mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
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/20210428182936.GE27406@telsasoft.com
This commit is contained in:
@@ -241,7 +241,7 @@ dataIsMoveRight(GinBtree btree, Page page)
|
||||
if (GinPageIsDeleted(page))
|
||||
return true;
|
||||
|
||||
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0) ? true : false;
|
||||
return (ginCompareItemPointers(&btree->itemptr, iptr) > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -100,7 +100,7 @@ initGinState(GinState *state, Relation index)
|
||||
MemSet(state, 0, sizeof(GinState));
|
||||
|
||||
state->index = index;
|
||||
state->oneCol = (origTupdesc->natts == 1) ? true : false;
|
||||
state->oneCol = (origTupdesc->natts == 1);
|
||||
state->origTupdesc = origTupdesc;
|
||||
|
||||
for (i = 0; i < origTupdesc->natts; i++)
|
||||
|
@@ -303,9 +303,9 @@ supportSecondarySplit(Relation r, GISTSTATE *giststate, int attno,
|
||||
penalty2 = gistpenalty(giststate, attno, entry1, false, &entrySR, false);
|
||||
|
||||
if (penalty1 < penalty2)
|
||||
leaveOnLeft = (sv->spl_ldatum_exists) ? true : false;
|
||||
leaveOnLeft = sv->spl_ldatum_exists;
|
||||
else
|
||||
leaveOnLeft = (sv->spl_rdatum_exists) ? true : false;
|
||||
leaveOnLeft = sv->spl_rdatum_exists;
|
||||
}
|
||||
|
||||
if (leaveOnLeft == false)
|
||||
|
@@ -816,7 +816,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
|
||||
XLogRecPtr recptr;
|
||||
|
||||
xlrec.clear_dead_marking = clear_dead_marking;
|
||||
xlrec.is_primary_bucket_page = (buf == bucket_buf) ? true : false;
|
||||
xlrec.is_primary_bucket_page = (buf == bucket_buf);
|
||||
|
||||
XLogBeginInsert();
|
||||
XLogRegisterData((char *) &xlrec, SizeOfHashDelete);
|
||||
|
@@ -176,7 +176,7 @@ restart_insert:
|
||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||
|
||||
/* chain to a new overflow page */
|
||||
buf = _hash_addovflpage(rel, metabuf, buf, (buf == bucket_buf) ? true : false);
|
||||
buf = _hash_addovflpage(rel, metabuf, buf, (buf == bucket_buf));
|
||||
page = BufferGetPage(buf);
|
||||
|
||||
/* should fit now, given test above */
|
||||
|
@@ -953,7 +953,7 @@ readpage:
|
||||
xl_hash_move_page_contents xlrec;
|
||||
|
||||
xlrec.ntups = nitups;
|
||||
xlrec.is_prim_bucket_same_wrt = (wbuf == bucket_buf) ? true : false;
|
||||
xlrec.is_prim_bucket_same_wrt = (wbuf == bucket_buf);
|
||||
|
||||
XLogBeginInsert();
|
||||
XLogRegisterData((char *) &xlrec, SizeOfHashMovePageContents);
|
||||
|
@@ -1195,7 +1195,7 @@ _hash_splitbucket(Relation rel,
|
||||
all_tups_size = 0;
|
||||
|
||||
/* chain to a new overflow page */
|
||||
nbuf = _hash_addovflpage(rel, metabuf, nbuf, (nbuf == bucket_nbuf) ? true : false);
|
||||
nbuf = _hash_addovflpage(rel, metabuf, nbuf, (nbuf == bucket_nbuf));
|
||||
npage = BufferGetPage(nbuf);
|
||||
nopaque = (HashPageOpaque) PageGetSpecialPointer(npage);
|
||||
}
|
||||
|
@@ -1475,7 +1475,7 @@ HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
|
||||
* all relevant hint bits were just set moments ago).
|
||||
*/
|
||||
if (!HeapTupleHeaderXminCommitted(tuple))
|
||||
return HeapTupleHeaderXminInvalid(tuple) ? true : false;
|
||||
return HeapTupleHeaderXminInvalid(tuple);
|
||||
|
||||
/*
|
||||
* If the inserting transaction committed, but any deleting transaction
|
||||
|
Reference in New Issue
Block a user