Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 68f7c4b

Browse files
committed
Clean up more code using "(expr) ? true : false"
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
1 parent 3eb1f4d commit 68f7c4b

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

contrib/ltree/ltree_op.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,42 +91,42 @@ Datum
9191
ltree_lt(PG_FUNCTION_ARGS)
9292
{
9393
RUNCMP;
94-
PG_RETURN_BOOL((res < 0) ? true : false);
94+
PG_RETURN_BOOL(res < 0);
9595
}
9696

9797
Datum
9898
ltree_le(PG_FUNCTION_ARGS)
9999
{
100100
RUNCMP;
101-
PG_RETURN_BOOL((res <= 0) ? true : false);
101+
PG_RETURN_BOOL(res <= 0);
102102
}
103103

104104
Datum
105105
ltree_eq(PG_FUNCTION_ARGS)
106106
{
107107
RUNCMP;
108-
PG_RETURN_BOOL((res == 0) ? true : false);
108+
PG_RETURN_BOOL(res == 0);
109109
}
110110

111111
Datum
112112
ltree_ge(PG_FUNCTION_ARGS)
113113
{
114114
RUNCMP;
115-
PG_RETURN_BOOL((res >= 0) ? true : false);
115+
PG_RETURN_BOOL(res >= 0);
116116
}
117117

118118
Datum
119119
ltree_gt(PG_FUNCTION_ARGS)
120120
{
121121
RUNCMP;
122-
PG_RETURN_BOOL((res > 0) ? true : false);
122+
PG_RETURN_BOOL(res > 0);
123123
}
124124

125125
Datum
126126
ltree_ne(PG_FUNCTION_ARGS)
127127
{
128128
RUNCMP;
129-
PG_RETURN_BOOL((res != 0) ? true : false);
129+
PG_RETURN_BOOL(res != 0);
130130
}
131131

132132
Datum

src/backend/access/gist/gistsplit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
421421
* Prepare spl_ldatum/spl_rdatum/spl_ldatum_exists/spl_rdatum_exists in
422422
* case we are doing a secondary split (see comments in gist.h).
423423
*/
424-
sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true;
425-
sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true;
424+
sv->spl_ldatum_exists = !(v->spl_lisnull[attno]);
425+
sv->spl_rdatum_exists = !(v->spl_risnull[attno]);
426426
sv->spl_ldatum = v->spl_lattr[attno];
427427
sv->spl_rdatum = v->spl_rattr[attno];
428428

@@ -451,8 +451,8 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
451451
* Reinit GIST_SPLITVEC. Although these fields are not used by
452452
* genericPickSplit(), set them up for further processing
453453
*/
454-
sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true;
455-
sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true;
454+
sv->spl_ldatum_exists = !(v->spl_lisnull[attno]);
455+
sv->spl_rdatum_exists = !(v->spl_risnull[attno]);
456456
sv->spl_ldatum = v->spl_lattr[attno];
457457
sv->spl_rdatum = v->spl_rattr[attno];
458458

src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7463,7 +7463,7 @@ ATExecColumnDefault(Relation rel, const char *colName,
74637463
* operation when the user asked for a drop.
74647464
*/
74657465
RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false,
7466-
newDefault == NULL ? false : true);
7466+
newDefault != NULL);
74677467

74687468
if (newDefault)
74697469
{

src/backend/executor/nodeResult.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ ExecInitResult(Result *node, EState *estate, int eflags)
195195
resstate->ps.ExecProcNode = ExecResult;
196196

197197
resstate->rs_done = false;
198-
resstate->rs_checkqual = (node->resconstantqual == NULL) ? false : true;
198+
resstate->rs_checkqual = (node->resconstantqual != NULL);
199199

200200
/*
201201
* Miscellaneous initialization
@@ -260,7 +260,7 @@ void
260260
ExecReScanResult(ResultState *node)
261261
{
262262
node->rs_done = false;
263-
node->rs_checkqual = (node->resconstantqual == NULL) ? false : true;
263+
node->rs_checkqual = (node->resconstantqual != NULL);
264264

265265
/*
266266
* If chgParam of subnode is not null then plan will be re-scanned by

src/backend/statistics/mcv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
16191619
Assert(mcvlist->nitems <= STATS_MCVLIST_MAX_ITEMS);
16201620

16211621
matches = palloc(sizeof(bool) * mcvlist->nitems);
1622-
memset(matches, (is_or) ? false : true,
1623-
sizeof(bool) * mcvlist->nitems);
1622+
memset(matches, !is_or, sizeof(bool) * mcvlist->nitems);
16241623

16251624
/*
16261625
* Loop through the list of clauses, and for each of them evaluate all the

src/backend/tsearch/ts_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ searchstoplist(StopList *s, char *key)
142142
{
143143
return (s->stop && s->len > 0 &&
144144
bsearch(&key, s->stop, s->len,
145-
sizeof(char *), pg_qsort_strcmp)) ? true : false;
145+
sizeof(char *), pg_qsort_strcmp));
146146
}

src/backend/tsearch/wparser_def.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ TParserGet(TParser *prs)
18561856
}
18571857
}
18581858

1859-
return (item && (item->flags & A_BINGO)) ? true : false;
1859+
return (item && (item->flags & A_BINGO));
18601860
}
18611861

18621862
Datum

0 commit comments

Comments
 (0)