mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Reduce excessive dereferencing of function pointers
It is equivalent in ANSI C to write (*funcptr) () and funcptr(). These two styles have been applied inconsistently. After discussion, we'll use the more verbose style for plain function pointer variables, to make it clear that it's a variable, and the shorter style when the function pointer is in a struct (s.func() or s->func()), because then it's clear that it's not a plain function name, and otherwise the excessive punctuation makes some of those invocations hard to read. Discussion: https://www.postgresql.org/message-id/f52c16db-14ed-757d-4b48-7ef360b1631d@2ndquadrant.com
This commit is contained in:
@ -220,7 +220,7 @@ fetch_cursor_param_value(ExprContext *econtext, int paramId)
|
||||
|
||||
/* give hook a chance in case parameter is dynamic */
|
||||
if (!OidIsValid(prm->ptype) && paramInfo->paramFetch != NULL)
|
||||
(*paramInfo->paramFetch) (paramInfo, paramId);
|
||||
paramInfo->paramFetch(paramInfo, paramId);
|
||||
|
||||
if (OidIsValid(prm->ptype) && !prm->isnull)
|
||||
{
|
||||
|
@ -647,7 +647,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
|
||||
|
||||
fcinfo->isnull = false;
|
||||
*op->resvalue = (op->d.func.fn_addr) (fcinfo);
|
||||
*op->resvalue = op->d.func.fn_addr(fcinfo);
|
||||
*op->resnull = fcinfo->isnull;
|
||||
|
||||
EEO_NEXT();
|
||||
@ -669,7 +669,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
}
|
||||
}
|
||||
fcinfo->isnull = false;
|
||||
*op->resvalue = (op->d.func.fn_addr) (fcinfo);
|
||||
*op->resvalue = op->d.func.fn_addr(fcinfo);
|
||||
*op->resnull = fcinfo->isnull;
|
||||
|
||||
strictfail:
|
||||
@ -684,7 +684,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
pgstat_init_function_usage(fcinfo, &fcusage);
|
||||
|
||||
fcinfo->isnull = false;
|
||||
*op->resvalue = (op->d.func.fn_addr) (fcinfo);
|
||||
*op->resvalue = op->d.func.fn_addr(fcinfo);
|
||||
*op->resnull = fcinfo->isnull;
|
||||
|
||||
pgstat_end_function_usage(&fcusage, true);
|
||||
@ -712,7 +712,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
pgstat_init_function_usage(fcinfo, &fcusage);
|
||||
|
||||
fcinfo->isnull = false;
|
||||
*op->resvalue = (op->d.func.fn_addr) (fcinfo);
|
||||
*op->resvalue = op->d.func.fn_addr(fcinfo);
|
||||
*op->resnull = fcinfo->isnull;
|
||||
|
||||
pgstat_end_function_usage(&fcusage, true);
|
||||
@ -1170,7 +1170,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
Datum eqresult;
|
||||
|
||||
fcinfo->isnull = false;
|
||||
eqresult = (op->d.func.fn_addr) (fcinfo);
|
||||
eqresult = op->d.func.fn_addr(fcinfo);
|
||||
/* Must invert result of "="; safe to do even if null */
|
||||
*op->resvalue = BoolGetDatum(!DatumGetBool(eqresult));
|
||||
*op->resnull = fcinfo->isnull;
|
||||
@ -1192,7 +1192,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
Datum result;
|
||||
|
||||
fcinfo->isnull = false;
|
||||
result = (op->d.func.fn_addr) (fcinfo);
|
||||
result = op->d.func.fn_addr(fcinfo);
|
||||
|
||||
/* if the arguments are equal return null */
|
||||
if (!fcinfo->isnull && DatumGetBool(result))
|
||||
@ -1279,7 +1279,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
|
||||
/* Apply comparison function */
|
||||
fcinfo->isnull = false;
|
||||
*op->resvalue = (op->d.rowcompare_step.fn_addr) (fcinfo);
|
||||
*op->resvalue = op->d.rowcompare_step.fn_addr(fcinfo);
|
||||
|
||||
/* force NULL result if NULL function result */
|
||||
if (fcinfo->isnull)
|
||||
@ -1878,7 +1878,7 @@ ExecEvalParamExtern(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
|
||||
|
||||
/* give hook a chance in case parameter is dynamic */
|
||||
if (!OidIsValid(prm->ptype) && paramInfo->paramFetch != NULL)
|
||||
(*paramInfo->paramFetch) (paramInfo, paramId);
|
||||
paramInfo->paramFetch(paramInfo, paramId);
|
||||
|
||||
if (likely(OidIsValid(prm->ptype)))
|
||||
{
|
||||
@ -3000,7 +3000,7 @@ ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
|
||||
else
|
||||
{
|
||||
fcinfo->isnull = false;
|
||||
thisresult = (op->d.scalararrayop.fn_addr) (fcinfo);
|
||||
thisresult = op->d.scalararrayop.fn_addr(fcinfo);
|
||||
}
|
||||
|
||||
/* Combine results per OR or AND semantics */
|
||||
|
@ -349,7 +349,7 @@ standard_ExecutorRun(QueryDesc *queryDesc,
|
||||
queryDesc->plannedstmt->hasReturning);
|
||||
|
||||
if (sendTuples)
|
||||
(*dest->rStartup) (dest, operation, queryDesc->tupDesc);
|
||||
dest->rStartup(dest, operation, queryDesc->tupDesc);
|
||||
|
||||
/*
|
||||
* run plan
|
||||
@ -375,7 +375,7 @@ standard_ExecutorRun(QueryDesc *queryDesc,
|
||||
* shutdown tuple receiver, if we started it
|
||||
*/
|
||||
if (sendTuples)
|
||||
(*dest->rShutdown) (dest);
|
||||
dest->rShutdown(dest);
|
||||
|
||||
if (queryDesc->totaltime)
|
||||
InstrStopNode(queryDesc->totaltime, estate->es_processed);
|
||||
@ -1752,7 +1752,7 @@ ExecutePlan(EState *estate,
|
||||
* has closed and no more tuples can be sent. If that's the case,
|
||||
* end the loop.
|
||||
*/
|
||||
if (!((*dest->receiveSlot) (slot, dest)))
|
||||
if (!dest->receiveSlot(slot, dest))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1081,5 +1081,5 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc)
|
||||
/* Cleanup. */
|
||||
dsa_detach(area);
|
||||
FreeQueryDesc(queryDesc);
|
||||
(*receiver->rDestroy) (receiver);
|
||||
receiver->rDestroy(receiver);
|
||||
}
|
||||
|
@ -1241,7 +1241,7 @@ begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc)
|
||||
tstate->slot = MakeSingleTupleTableSlot(tupdesc);
|
||||
tstate->dest = dest;
|
||||
|
||||
(*tstate->dest->rStartup) (tstate->dest, (int) CMD_SELECT, tupdesc);
|
||||
tstate->dest->rStartup(tstate->dest, (int) CMD_SELECT, tupdesc);
|
||||
|
||||
return tstate;
|
||||
}
|
||||
@ -1266,7 +1266,7 @@ do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
|
||||
ExecStoreVirtualTuple(slot);
|
||||
|
||||
/* send the tuple to the receiver */
|
||||
(void) (*tstate->dest->receiveSlot) (slot, tstate->dest);
|
||||
(void) tstate->dest->receiveSlot(slot, tstate->dest);
|
||||
|
||||
/* clean up */
|
||||
ExecClearTuple(slot);
|
||||
@ -1310,7 +1310,7 @@ do_text_output_multiline(TupOutputState *tstate, const char *txt)
|
||||
void
|
||||
end_tup_output(TupOutputState *tstate)
|
||||
{
|
||||
(*tstate->dest->rShutdown) (tstate->dest);
|
||||
tstate->dest->rShutdown(tstate->dest);
|
||||
/* note that destroying the dest is not ours to do */
|
||||
ExecDropSingleTupleTableSlot(tstate->slot);
|
||||
pfree(tstate);
|
||||
|
@ -813,7 +813,7 @@ ShutdownExprContext(ExprContext *econtext, bool isCommit)
|
||||
{
|
||||
econtext->ecxt_callbacks = ecxt_callback->next;
|
||||
if (isCommit)
|
||||
(*ecxt_callback->function) (ecxt_callback->arg);
|
||||
ecxt_callback->function(ecxt_callback->arg);
|
||||
pfree(ecxt_callback);
|
||||
}
|
||||
|
||||
|
@ -886,7 +886,7 @@ postquel_end(execution_state *es)
|
||||
ExecutorEnd(es->qd);
|
||||
}
|
||||
|
||||
(*es->qd->dest->rDestroy) (es->qd->dest);
|
||||
es->qd->dest->rDestroy(es->qd->dest);
|
||||
|
||||
FreeQueryDesc(es->qd);
|
||||
es->qd = NULL;
|
||||
|
Reference in New Issue
Block a user