Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd0625c

Browse files
committed
Clean up some code using "(expr) ? true : false"
All the code paths simplified here were already using a boolean or usedan expression that led to zero or one, making the extra bitsunnecessary.Author: Justin PryzbyReviewed-by: Tom Lane, Michael Paquier, Peter SmithDiscussion:https://postgr.es/m/20210428182936.GE27406@telsasoft.com
1 parentd6c916f commitfd0625c

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
int32i;

‎contrib/sepgsql/selinux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static intsepgsql_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
XLogRecPtrrecptr;
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_contentsxlrec;
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
}

‎src/backend/access/heap/heapam_visibility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
14751475
* all relevant hint bits were just set moments ago).
14761476
*/
14771477
if (!HeapTupleHeaderXminCommitted(tuple))
1478-
returnHeapTupleHeaderXminInvalid(tuple) ? true : false;
1478+
returnHeapTupleHeaderXminInvalid(tuple);
14791479

14801480
/*
14811481
* If the inserting transaction committed, but any deleting transaction

‎src/backend/executor/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
10371037
if (attnum[i] <=0||attnum[i]>numberOfAttributes)
10381038
break;
10391039
v[attnum[i]-1]=Values[i];
1040-
n[attnum[i]-1]= (Nulls&&Nulls[i]=='n') ? true : false;
1040+
n[attnum[i]-1]= (Nulls&&Nulls[i]=='n');
10411041
}
10421042

10431043
if (i==natts)/* no errors in *attnum */

‎src/backend/jit/jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ file_exists(const char *name)
198198
AssertArg(name!=NULL);
199199

200200
if (stat(name,&st)==0)
201-
returnS_ISDIR(st.st_mode) ? false : true;
201+
return!S_ISDIR(st.st_mode);
202202
elseif (!(errno==ENOENT||errno==ENOTDIR))
203203
ereport(ERROR,
204204
(errcode_for_file_access(),

‎src/backend/optimizer/util/pathnode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ create_seqscan_path(PlannerInfo *root, RelOptInfo *rel,
936936
pathnode->pathtarget=rel->reltarget;
937937
pathnode->param_info=get_baserel_parampathinfo(root,rel,
938938
required_outer);
939-
pathnode->parallel_aware=parallel_workers>0 ? true : false;
939+
pathnode->parallel_aware=(parallel_workers>0);
940940
pathnode->parallel_safe=rel->consider_parallel;
941941
pathnode->parallel_workers=parallel_workers;
942942
pathnode->pathkeys=NIL;/* seqscan has unordered result */
@@ -1057,7 +1057,7 @@ create_bitmap_heap_path(PlannerInfo *root,
10571057
pathnode->path.pathtarget=rel->reltarget;
10581058
pathnode->path.param_info=get_baserel_parampathinfo(root,rel,
10591059
required_outer);
1060-
pathnode->path.parallel_aware=parallel_degree>0 ? true : false;
1060+
pathnode->path.parallel_aware=(parallel_degree>0);
10611061
pathnode->path.parallel_safe=rel->consider_parallel;
10621062
pathnode->path.parallel_workers=parallel_degree;
10631063
pathnode->path.pathkeys=NIL;/* always unordered */

‎src/backend/statistics/mcv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
17721772
for (i=0;i<mcvlist->nitems;i++)
17731773
{
17741774
intj;
1775-
boolmatch=(expr->useOr ? false : true);
1775+
boolmatch=!expr->useOr;
17761776
MCVItem*item=&mcvlist->items[i];
17771777

17781778
/*

‎src/backend/storage/file/buffile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ BufFileOpenFileSet(FileSet *fileset, const char *name, int mode,
336336

337337
file=makeBufFileCommon(nfiles);
338338
file->files=files;
339-
file->readOnly= (mode==O_RDONLY) ? true : false;
339+
file->readOnly= (mode==O_RDONLY);
340340
file->fileset=fileset;
341341
file->name=pstrdup(name);
342342

‎src/backend/tsearch/ts_parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
288288
}
289289
}
290290

291-
ld->dictState.isend= (curVal->type==0) ? true : false;
291+
ld->dictState.isend= (curVal->type==0);
292292
ld->dictState.getnext= false;
293293

294294
res= (TSLexeme*)DatumGetPointer(FunctionCall4(&(dict->lexize),

‎src/backend/utils/adt/bool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ boolrecv(PG_FUNCTION_ARGS)
184184
intext;
185185

186186
ext=pq_getmsgbyte(buf);
187-
PG_RETURN_BOOL((ext!=0) ? true : false);
187+
PG_RETURN_BOOL(ext!=0);
188188
}
189189

190190
/*

‎src/backend/utils/adt/ruleutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8005,14 +8005,14 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
80058005
* appears simple since . has top precedence, unless parent is
80068006
* T_FieldSelect itself!
80078007
*/
8008-
return(IsA(parentNode,FieldSelect) ? false : true);
8008+
return!IsA(parentNode,FieldSelect);
80098009

80108010
caseT_FieldStore:
80118011

80128012
/*
80138013
* treat like FieldSelect (probably doesn't matter)
80148014
*/
8015-
return(IsA(parentNode,FieldStore) ? false : true);
8015+
return!IsA(parentNode,FieldStore);
80168016

80178017
caseT_CoerceToDomain:
80188018
/* maybe simple, check args */

‎src/backend/utils/adt/tsquery_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ gtsquery_same(PG_FUNCTION_ARGS)
109109
TSQuerySignb=PG_GETARG_TSQUERYSIGN(1);
110110
bool*result= (bool*)PG_GETARG_POINTER(2);
111111

112-
*result= (a==b) ? true : false;
112+
*result= (a==b);
113113

114114
PG_RETURN_POINTER(result);
115115
}

‎src/backend/utils/adt/tsquery_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ QTNEq(QTNode *a, QTNode *b)
186186
if (!(sign==a->sign&&sign==b->sign))
187187
return false;
188188

189-
return (QTNodeCompare(a,b)==0) ? true : false;
189+
return (QTNodeCompare(a,b)==0);
190190
}
191191

192192
/*

‎src/backend/utils/fmgr/dfmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ file_exists(const char *name)
458458
AssertArg(name!=NULL);
459459

460460
if (stat(name,&st)==0)
461-
returnS_ISDIR(st.st_mode) ? false : true;
461+
return!S_ISDIR(st.st_mode);
462462
elseif (!(errno==ENOENT||errno==ENOTDIR||errno==EACCES))
463463
ereport(ERROR,
464464
(errcode_for_file_access(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp