Clean up more code using "(expr) ? true : false"
authorMichael Paquier <[email protected]>
Mon, 11 Oct 2021 00:36:42 +0000 (09:36 +0900)
committerMichael Paquier <[email protected]>
Mon, 11 Oct 2021 00:36:42 +0000 (09:36 +0900)
This is similar to fd0625c, taking care of any remaining code paths that
are worth the cleanup.  This also changes some cases using opposite
expression patterns.

Author: Justin Pryzby, Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoCdF8dnUvr-BUWWGvA_XhKSoANacBMZb6jKyCk4TYfQ2Q@mail.gmail.com

contrib/ltree/ltree_op.c
src/backend/access/gist/gistsplit.c
src/backend/commands/tablecmds.c
src/backend/executor/nodeResult.c
src/backend/statistics/mcv.c
src/backend/tsearch/ts_utils.c
src/backend/tsearch/wparser_def.c

index 778dbf1e980092879dfaf67c43b7bd97f7ba398b..da1db5fcd2229b23fd8d2c0fbc1497416586022a 100644 (file)
@@ -91,42 +91,42 @@ Datum
 ltree_lt(PG_FUNCTION_ARGS)
 {
    RUNCMP;
-   PG_RETURN_BOOL((res < 0) ? true : false);
+   PG_RETURN_BOOL(res < 0);
 }
 
 Datum
 ltree_le(PG_FUNCTION_ARGS)
 {
    RUNCMP;
-   PG_RETURN_BOOL((res <= 0) ? true : false);
+   PG_RETURN_BOOL(res <= 0);
 }
 
 Datum
 ltree_eq(PG_FUNCTION_ARGS)
 {
    RUNCMP;
-   PG_RETURN_BOOL((res == 0) ? true : false);
+   PG_RETURN_BOOL(res == 0);
 }
 
 Datum
 ltree_ge(PG_FUNCTION_ARGS)
 {
    RUNCMP;
-   PG_RETURN_BOOL((res >= 0) ? true : false);
+   PG_RETURN_BOOL(res >= 0);
 }
 
 Datum
 ltree_gt(PG_FUNCTION_ARGS)
 {
    RUNCMP;
-   PG_RETURN_BOOL((res > 0) ? true : false);
+   PG_RETURN_BOOL(res > 0);
 }
 
 Datum
 ltree_ne(PG_FUNCTION_ARGS)
 {
    RUNCMP;
-   PG_RETURN_BOOL((res != 0) ? true : false);
+   PG_RETURN_BOOL(res != 0);
 }
 
 Datum
index 853ebc387b4a0207dd88cfee5156cbb56684df9d..1c5d4e9ca22d3fdb674d87e3aca90f017ca328fc 100644 (file)
@@ -421,8 +421,8 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
     * Prepare spl_ldatum/spl_rdatum/spl_ldatum_exists/spl_rdatum_exists in
     * case we are doing a secondary split (see comments in gist.h).
     */
-   sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true;
-   sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true;
+   sv->spl_ldatum_exists = !(v->spl_lisnull[attno]);
+   sv->spl_rdatum_exists = !(v->spl_risnull[attno]);
    sv->spl_ldatum = v->spl_lattr[attno];
    sv->spl_rdatum = v->spl_rattr[attno];
 
@@ -451,8 +451,8 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
         * Reinit GIST_SPLITVEC. Although these fields are not used by
         * genericPickSplit(), set them up for further processing
         */
-       sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true;
-       sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true;
+       sv->spl_ldatum_exists = !(v->spl_lisnull[attno]);
+       sv->spl_rdatum_exists = !(v->spl_risnull[attno]);
        sv->spl_ldatum = v->spl_lattr[attno];
        sv->spl_rdatum = v->spl_rattr[attno];
 
index ff97b618e6331152fbcefd8d5395dd4fdbcf3e9d..1c2ebe1bf69537b65fa8a55ca91a57418d7aec76 100644 (file)
@@ -7463,7 +7463,7 @@ ATExecColumnDefault(Relation rel, const char *colName,
     * operation when the user asked for a drop.
     */
    RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false,
-                     newDefault == NULL ? false : true);
+                     newDefault != NULL);
 
    if (newDefault)
    {
index 0946af0a549a317241bae4261d4090addb6a1923..a8d308c66025b3737fc72418942dae5599940997 100644 (file)
@@ -195,7 +195,7 @@ ExecInitResult(Result *node, EState *estate, int eflags)
    resstate->ps.ExecProcNode = ExecResult;
 
    resstate->rs_done = false;
-   resstate->rs_checkqual = (node->resconstantqual == NULL) ? false : true;
+   resstate->rs_checkqual = (node->resconstantqual != NULL);
 
    /*
     * Miscellaneous initialization
@@ -260,7 +260,7 @@ void
 ExecReScanResult(ResultState *node)
 {
    node->rs_done = false;
-   node->rs_checkqual = (node->resconstantqual == NULL) ? false : true;
+   node->rs_checkqual = (node->resconstantqual != NULL);
 
    /*
     * If chgParam of subnode is not null then plan will be re-scanned by
index 35b39ece0754e2db12d06c2a6f82bf4b3d65a749..b350fc5f7b292dff802c463551d60e495913bdd2 100644 (file)
@@ -1619,8 +1619,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
    Assert(mcvlist->nitems <= STATS_MCVLIST_MAX_ITEMS);
 
    matches = palloc(sizeof(bool) * mcvlist->nitems);
-   memset(matches, (is_or) ? false : true,
-          sizeof(bool) * mcvlist->nitems);
+   memset(matches, !is_or,  sizeof(bool) * mcvlist->nitems);
 
    /*
     * Loop through the list of clauses, and for each of them evaluate all the
index ed16a2e25a2a8120a2dc10ed256f7464703ea6eb..9539cf1326bb45d28d1be1319cb15d0c676adc55 100644 (file)
@@ -142,5 +142,5 @@ searchstoplist(StopList *s, char *key)
 {
    return (s->stop && s->len > 0 &&
            bsearch(&key, s->stop, s->len,
-                   sizeof(char *), pg_qsort_strcmp)) ? true : false;
+                   sizeof(char *), pg_qsort_strcmp));
 }
index 559dff635588d03a4e091bed66a232f4dbf67963..537c701cc7f43732cf0be168caab589581c7f169 100644 (file)
@@ -1856,7 +1856,7 @@ TParserGet(TParser *prs)
        }
    }
 
-   return (item && (item->flags & A_BINGO)) ? true : false;
+   return (item && (item->flags & A_BINGO));
 }
 
 Datum