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

Commit1356f78

Browse files
committed
Reduce excessive dereferencing of function pointers
It is equivalent in ANSI C to write (*funcptr) () and funcptr(). Thesetwo styles have been applied inconsistently. After discussion, we'lluse the more verbose style for plain function pointer variables, to makeit clear that it's a variable, and the shorter style when the functionpointer is in a struct (s.func() or s->func()), because then it's clearthat it's not a plain function name, and otherwise the excessivepunctuation makes some of those invocations hard to read.Discussion:https://www.postgresql.org/message-id/f52c16db-14ed-757d-4b48-7ef360b1631d@2ndquadrant.com
1 parent9d71323 commit1356f78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+249
-250
lines changed

‎contrib/btree_gist/btree_utils_num.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin
184184
c.lower=&cur[0];
185185
c.upper=&cur[tinfo->size];
186186
/* if out->lower > cur->lower, adopt cur as lower */
187-
if ((*tinfo->f_gt)(o.lower,c.lower,flinfo))
187+
if (tinfo->f_gt(o.lower,c.lower,flinfo))
188188
memcpy((void*)o.lower, (void*)c.lower,tinfo->size);
189189
/* if out->upper < cur->upper, adopt cur as upper */
190-
if ((*tinfo->f_lt)(o.upper,c.upper,flinfo))
190+
if (tinfo->f_lt(o.upper,c.upper,flinfo))
191191
memcpy((void*)o.upper, (void*)c.upper,tinfo->size);
192192
}
193193

@@ -211,8 +211,8 @@ gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo
211211
b2.lower=&(((GBT_NUMKEY*)b)[0]);
212212
b2.upper=&(((GBT_NUMKEY*)b)[tinfo->size]);
213213

214-
return ((*tinfo->f_eq)(b1.lower,b2.lower,flinfo)&&
215-
(*tinfo->f_eq)(b1.upper,b2.upper,flinfo));
214+
return (tinfo->f_eq(b1.lower,b2.lower,flinfo)&&
215+
tinfo->f_eq(b1.upper,b2.upper,flinfo));
216216
}
217217

218218

@@ -236,9 +236,9 @@ gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo, FmgrInfo *
236236

237237
ur.lower=&(((GBT_NUMKEY*)DatumGetPointer(*u))[0]);
238238
ur.upper=&(((GBT_NUMKEY*)DatumGetPointer(*u))[tinfo->size]);
239-
if ((*tinfo->f_gt)((void*)ur.lower, (void*)rd.lower,flinfo))
239+
if (tinfo->f_gt((void*)ur.lower, (void*)rd.lower,flinfo))
240240
memcpy((void*)ur.lower, (void*)rd.lower,tinfo->size);
241-
if ((*tinfo->f_lt)((void*)ur.upper, (void*)rd.upper,flinfo))
241+
if (tinfo->f_lt((void*)ur.upper, (void*)rd.upper,flinfo))
242242
memcpy((void*)ur.upper, (void*)rd.upper,tinfo->size);
243243
}
244244
}
@@ -264,33 +264,33 @@ gbt_num_consistent(const GBT_NUMKEY_R *key,
264264
switch (*strategy)
265265
{
266266
caseBTLessEqualStrategyNumber:
267-
retval=(*tinfo->f_ge)(query,key->lower,flinfo);
267+
retval=tinfo->f_ge(query,key->lower,flinfo);
268268
break;
269269
caseBTLessStrategyNumber:
270270
if (is_leaf)
271-
retval=(*tinfo->f_gt)(query,key->lower,flinfo);
271+
retval=tinfo->f_gt(query,key->lower,flinfo);
272272
else
273-
retval=(*tinfo->f_ge)(query,key->lower,flinfo);
273+
retval=tinfo->f_ge(query,key->lower,flinfo);
274274
break;
275275
caseBTEqualStrategyNumber:
276276
if (is_leaf)
277-
retval=(*tinfo->f_eq)(query,key->lower,flinfo);
277+
retval=tinfo->f_eq(query,key->lower,flinfo);
278278
else
279-
retval= ((*tinfo->f_le)(key->lower,query,flinfo)&&
280-
(*tinfo->f_le)(query,key->upper,flinfo));
279+
retval= (tinfo->f_le(key->lower,query,flinfo)&&
280+
tinfo->f_le(query,key->upper,flinfo));
281281
break;
282282
caseBTGreaterStrategyNumber:
283283
if (is_leaf)
284-
retval=(*tinfo->f_lt)(query,key->upper,flinfo);
284+
retval=tinfo->f_lt(query,key->upper,flinfo);
285285
else
286-
retval=(*tinfo->f_le)(query,key->upper,flinfo);
286+
retval=tinfo->f_le(query,key->upper,flinfo);
287287
break;
288288
caseBTGreaterEqualStrategyNumber:
289-
retval=(*tinfo->f_le)(query,key->upper,flinfo);
289+
retval=tinfo->f_le(query,key->upper,flinfo);
290290
break;
291291
caseBtreeGistNotEqualStrategyNumber:
292-
retval= (!((*tinfo->f_eq)(query,key->lower,flinfo)&&
293-
(*tinfo->f_eq)(query,key->upper,flinfo)));
292+
retval= (!(tinfo->f_eq(query,key->lower,flinfo)&&
293+
tinfo->f_eq(query,key->upper,flinfo)));
294294
break;
295295
default:
296296
retval= false;

‎contrib/btree_gist/btree_utils_var.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ gbt_var_leaf2node(GBT_VARKEY *leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
109109
GBT_VARKEY*out=leaf;
110110

111111
if (tinfo->f_l2n)
112-
out=(*tinfo->f_l2n)(leaf,flinfo);
112+
out=tinfo->f_l2n(leaf,flinfo);
113113

114114
returnout;
115115
}
@@ -255,13 +255,13 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
255255
nr.lower=ro.lower;
256256
nr.upper=ro.upper;
257257

258-
if ((*tinfo->f_cmp)(ro.lower,eo.lower,collation,flinfo)>0)
258+
if (tinfo->f_cmp(ro.lower,eo.lower,collation,flinfo)>0)
259259
{
260260
nr.lower=eo.lower;
261261
update= true;
262262
}
263263

264-
if ((*tinfo->f_cmp)(ro.upper,eo.upper,collation,flinfo)<0)
264+
if (tinfo->f_cmp(ro.upper,eo.upper,collation,flinfo)<0)
265265
{
266266
nr.upper=eo.upper;
267267
update= true;
@@ -371,8 +371,8 @@ gbt_var_same(Datum d1, Datum d2, Oid collation,
371371
r1=gbt_var_key_readable(t1);
372372
r2=gbt_var_key_readable(t2);
373373

374-
return ((*tinfo->f_cmp)(r1.lower,r2.lower,collation,flinfo)==0&&
375-
(*tinfo->f_cmp)(r1.upper,r2.upper,collation,flinfo)==0);
374+
return (tinfo->f_cmp(r1.lower,r2.lower,collation,flinfo)==0&&
375+
tinfo->f_cmp(r1.upper,r2.upper,collation,flinfo)==0);
376376
}
377377

378378

@@ -400,9 +400,9 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
400400

401401
if ((VARSIZE(ok.lower)-VARHDRSZ)==0&& (VARSIZE(ok.upper)-VARHDRSZ)==0)
402402
*res=0.0;
403-
elseif (!(((*tinfo->f_cmp)(nk.lower,ok.lower,collation,flinfo) >=0||
403+
elseif (!((tinfo->f_cmp(nk.lower,ok.lower,collation,flinfo) >=0||
404404
gbt_bytea_pf_match(ok.lower,nk.lower,tinfo))&&
405-
((*tinfo->f_cmp)(nk.upper,ok.upper,collation,flinfo) <=0||
405+
(tinfo->f_cmp(nk.upper,ok.upper,collation,flinfo) <=0||
406406
gbt_bytea_pf_match(ok.upper,nk.upper,tinfo))))
407407
{
408408
Datumd=PointerGetDatum(0);
@@ -449,9 +449,9 @@ gbt_vsrt_cmp(const void *a, const void *b, void *arg)
449449
constgbt_vsrt_arg*varg= (constgbt_vsrt_arg*)arg;
450450
intres;
451451

452-
res=(*varg->tinfo->f_cmp)(ar.lower,br.lower,varg->collation,varg->flinfo);
452+
res=varg->tinfo->f_cmp(ar.lower,br.lower,varg->collation,varg->flinfo);
453453
if (res==0)
454-
return(*varg->tinfo->f_cmp)(ar.upper,br.upper,varg->collation,varg->flinfo);
454+
returnvarg->tinfo->f_cmp(ar.upper,br.upper,varg->collation,varg->flinfo);
455455

456456
returnres;
457457
}
@@ -567,44 +567,44 @@ gbt_var_consistent(GBT_VARKEY_R *key,
567567
{
568568
caseBTLessEqualStrategyNumber:
569569
if (is_leaf)
570-
retval=(*tinfo->f_ge)(query,key->lower,collation,flinfo);
570+
retval=tinfo->f_ge(query,key->lower,collation,flinfo);
571571
else
572-
retval=(*tinfo->f_cmp)(query,key->lower,collation,flinfo) >=0
572+
retval=tinfo->f_cmp(query,key->lower,collation,flinfo) >=0
573573
||gbt_var_node_pf_match(key,query,tinfo);
574574
break;
575575
caseBTLessStrategyNumber:
576576
if (is_leaf)
577-
retval=(*tinfo->f_gt)(query,key->lower,collation,flinfo);
577+
retval=tinfo->f_gt(query,key->lower,collation,flinfo);
578578
else
579-
retval=(*tinfo->f_cmp)(query,key->lower,collation,flinfo) >=0
579+
retval=tinfo->f_cmp(query,key->lower,collation,flinfo) >=0
580580
||gbt_var_node_pf_match(key,query,tinfo);
581581
break;
582582
caseBTEqualStrategyNumber:
583583
if (is_leaf)
584-
retval=(*tinfo->f_eq)(query,key->lower,collation,flinfo);
584+
retval=tinfo->f_eq(query,key->lower,collation,flinfo);
585585
else
586586
retval=
587-
((*tinfo->f_cmp)(key->lower,query,collation,flinfo) <=0&&
588-
(*tinfo->f_cmp)(query,key->upper,collation,flinfo) <=0)||
587+
(tinfo->f_cmp(key->lower,query,collation,flinfo) <=0&&
588+
tinfo->f_cmp(query,key->upper,collation,flinfo) <=0)||
589589
gbt_var_node_pf_match(key,query,tinfo);
590590
break;
591591
caseBTGreaterStrategyNumber:
592592
if (is_leaf)
593-
retval=(*tinfo->f_lt)(query,key->upper,collation,flinfo);
593+
retval=tinfo->f_lt(query,key->upper,collation,flinfo);
594594
else
595-
retval=(*tinfo->f_cmp)(query,key->upper,collation,flinfo) <=0
595+
retval=tinfo->f_cmp(query,key->upper,collation,flinfo) <=0
596596
||gbt_var_node_pf_match(key,query,tinfo);
597597
break;
598598
caseBTGreaterEqualStrategyNumber:
599599
if (is_leaf)
600-
retval=(*tinfo->f_le)(query,key->upper,collation,flinfo);
600+
retval=tinfo->f_le(query,key->upper,collation,flinfo);
601601
else
602-
retval=(*tinfo->f_cmp)(query,key->upper,collation,flinfo) <=0
602+
retval=tinfo->f_cmp(query,key->upper,collation,flinfo) <=0
603603
||gbt_var_node_pf_match(key,query,tinfo);
604604
break;
605605
caseBtreeGistNotEqualStrategyNumber:
606-
retval= !((*tinfo->f_eq)(query,key->lower,collation,flinfo)&&
607-
(*tinfo->f_eq)(query,key->upper,collation,flinfo));
606+
retval= !(tinfo->f_eq(query,key->lower,collation,flinfo)&&
607+
tinfo->f_eq(query,key->upper,collation,flinfo));
608608
break;
609609
default:
610610
retval= FALSE;

‎src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,7 @@ CallXactCallbacks(XactEvent event)
33473347
XactCallbackItem*item;
33483348

33493349
for (item=Xact_callbacks;item;item=item->next)
3350-
(*item->callback)(event,item->arg);
3350+
item->callback(event,item->arg);
33513351
}
33523352

33533353

@@ -3404,7 +3404,7 @@ CallSubXactCallbacks(SubXactEvent event,
34043404
SubXactCallbackItem*item;
34053405

34063406
for (item=SubXact_callbacks;item;item=item->next)
3407-
(*item->callback)(event,mySubid,parentSubid,item->arg);
3407+
item->callback(event,mySubid,parentSubid,item->arg);
34083408
}
34093409

34103410

‎src/backend/commands/analyze.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ do_analyze_rel(Relation onerel, int options, VacuumParams *params,
526526

527527
stats->rows=rows;
528528
stats->tupDesc=onerel->rd_att;
529-
(*stats->compute_stats)(stats,
529+
stats->compute_stats(stats,
530530
std_fetch_func,
531531
numrows,
532532
totalrows);
@@ -830,7 +830,7 @@ compute_index_stats(Relation onerel, double totalrows,
830830
stats->exprvals=exprvals+i;
831831
stats->exprnulls=exprnulls+i;
832832
stats->rowstride=attr_cnt;
833-
(*stats->compute_stats)(stats,
833+
stats->compute_stats(stats,
834834
ind_fetch_func,
835835
numindexrows,
836836
totalindexrows);

‎src/backend/commands/portalcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ PersistHoldablePortal(Portal portal)
397397
/* Fetch the result set into the tuplestore */
398398
ExecutorRun(queryDesc,ForwardScanDirection,0L, false);
399399

400-
(*queryDesc->dest->rDestroy)(queryDesc->dest);
400+
queryDesc->dest->rDestroy(queryDesc->dest);
401401
queryDesc->dest=NULL;
402402

403403
/*

‎src/backend/commands/seclabel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
122122
}
123123

124124
/* Provider gets control here, may throw ERROR to veto new label. */
125-
(*provider->hook)(&address,stmt->label);
125+
provider->hook(&address,stmt->label);
126126

127127
/* Apply new label. */
128128
SetSecurityLabel(&address,provider->provider_name,stmt->label);

‎src/backend/executor/execCurrent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fetch_cursor_param_value(ExprContext *econtext, int paramId)
220220

221221
/* give hook a chance in case parameter is dynamic */
222222
if (!OidIsValid(prm->ptype)&&paramInfo->paramFetch!=NULL)
223-
(*paramInfo->paramFetch)(paramInfo,paramId);
223+
paramInfo->paramFetch(paramInfo,paramId);
224224

225225
if (OidIsValid(prm->ptype)&& !prm->isnull)
226226
{

‎src/backend/executor/execExprInterp.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
647647
FunctionCallInfofcinfo=op->d.func.fcinfo_data;
648648

649649
fcinfo->isnull= false;
650-
*op->resvalue=(op->d.func.fn_addr)(fcinfo);
650+
*op->resvalue=op->d.func.fn_addr(fcinfo);
651651
*op->resnull=fcinfo->isnull;
652652

653653
EEO_NEXT();
@@ -669,7 +669,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
669669
}
670670
}
671671
fcinfo->isnull= false;
672-
*op->resvalue=(op->d.func.fn_addr)(fcinfo);
672+
*op->resvalue=op->d.func.fn_addr(fcinfo);
673673
*op->resnull=fcinfo->isnull;
674674

675675
strictfail:
@@ -684,7 +684,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
684684
pgstat_init_function_usage(fcinfo,&fcusage);
685685

686686
fcinfo->isnull= false;
687-
*op->resvalue=(op->d.func.fn_addr)(fcinfo);
687+
*op->resvalue=op->d.func.fn_addr(fcinfo);
688688
*op->resnull=fcinfo->isnull;
689689

690690
pgstat_end_function_usage(&fcusage, true);
@@ -712,7 +712,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
712712
pgstat_init_function_usage(fcinfo,&fcusage);
713713

714714
fcinfo->isnull= false;
715-
*op->resvalue=(op->d.func.fn_addr)(fcinfo);
715+
*op->resvalue=op->d.func.fn_addr(fcinfo);
716716
*op->resnull=fcinfo->isnull;
717717

718718
pgstat_end_function_usage(&fcusage, true);
@@ -1170,7 +1170,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
11701170
Datumeqresult;
11711171

11721172
fcinfo->isnull= false;
1173-
eqresult=(op->d.func.fn_addr)(fcinfo);
1173+
eqresult=op->d.func.fn_addr(fcinfo);
11741174
/* Must invert result of "="; safe to do even if null */
11751175
*op->resvalue=BoolGetDatum(!DatumGetBool(eqresult));
11761176
*op->resnull=fcinfo->isnull;
@@ -1192,7 +1192,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
11921192
Datumresult;
11931193

11941194
fcinfo->isnull= false;
1195-
result=(op->d.func.fn_addr)(fcinfo);
1195+
result=op->d.func.fn_addr(fcinfo);
11961196

11971197
/* if the arguments are equal return null */
11981198
if (!fcinfo->isnull&&DatumGetBool(result))
@@ -1279,7 +1279,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
12791279

12801280
/* Apply comparison function */
12811281
fcinfo->isnull= false;
1282-
*op->resvalue=(op->d.rowcompare_step.fn_addr)(fcinfo);
1282+
*op->resvalue=op->d.rowcompare_step.fn_addr(fcinfo);
12831283

12841284
/* force NULL result if NULL function result */
12851285
if (fcinfo->isnull)
@@ -1878,7 +1878,7 @@ ExecEvalParamExtern(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
18781878

18791879
/* give hook a chance in case parameter is dynamic */
18801880
if (!OidIsValid(prm->ptype)&&paramInfo->paramFetch!=NULL)
1881-
(*paramInfo->paramFetch)(paramInfo,paramId);
1881+
paramInfo->paramFetch(paramInfo,paramId);
18821882

18831883
if (likely(OidIsValid(prm->ptype)))
18841884
{
@@ -3000,7 +3000,7 @@ ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
30003000
else
30013001
{
30023002
fcinfo->isnull= false;
3003-
thisresult=(op->d.scalararrayop.fn_addr)(fcinfo);
3003+
thisresult=op->d.scalararrayop.fn_addr(fcinfo);
30043004
}
30053005

30063006
/* Combine results per OR or AND semantics */

‎src/backend/executor/execMain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ standard_ExecutorRun(QueryDesc *queryDesc,
349349
queryDesc->plannedstmt->hasReturning);
350350

351351
if (sendTuples)
352-
(*dest->rStartup)(dest,operation,queryDesc->tupDesc);
352+
dest->rStartup(dest,operation,queryDesc->tupDesc);
353353

354354
/*
355355
* run plan
@@ -375,7 +375,7 @@ standard_ExecutorRun(QueryDesc *queryDesc,
375375
* shutdown tuple receiver, if we started it
376376
*/
377377
if (sendTuples)
378-
(*dest->rShutdown)(dest);
378+
dest->rShutdown(dest);
379379

380380
if (queryDesc->totaltime)
381381
InstrStopNode(queryDesc->totaltime,estate->es_processed);
@@ -1752,7 +1752,7 @@ ExecutePlan(EState *estate,
17521752
* has closed and no more tuples can be sent. If that's the case,
17531753
* end the loop.
17541754
*/
1755-
if (!((*dest->receiveSlot)(slot,dest)))
1755+
if (!dest->receiveSlot(slot,dest))
17561756
break;
17571757
}
17581758

‎src/backend/executor/execParallel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,5 +1081,5 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc)
10811081
/* Cleanup. */
10821082
dsa_detach(area);
10831083
FreeQueryDesc(queryDesc);
1084-
(*receiver->rDestroy)(receiver);
1084+
receiver->rDestroy(receiver);
10851085
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp