1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-26 23:43:30 +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:
Peter Eisentraut
2017-09-07 12:06:23 -04:00
parent 9d71323dac
commit 1356f78ea9
46 changed files with 249 additions and 250 deletions

View File

@@ -197,8 +197,8 @@ proc_exit_prepare(int code)
* possible.
*/
while (--on_proc_exit_index >= 0)
(*on_proc_exit_list[on_proc_exit_index].function) (code,
on_proc_exit_list[on_proc_exit_index].arg);
on_proc_exit_list[on_proc_exit_index].function(code,
on_proc_exit_list[on_proc_exit_index].arg);
on_proc_exit_index = 0;
}
@@ -225,8 +225,8 @@ shmem_exit(int code)
elog(DEBUG3, "shmem_exit(%d): %d before_shmem_exit callbacks to make",
code, before_shmem_exit_index);
while (--before_shmem_exit_index >= 0)
(*before_shmem_exit_list[before_shmem_exit_index].function) (code,
before_shmem_exit_list[before_shmem_exit_index].arg);
before_shmem_exit_list[before_shmem_exit_index].function(code,
before_shmem_exit_list[before_shmem_exit_index].arg);
before_shmem_exit_index = 0;
/*
@@ -258,8 +258,8 @@ shmem_exit(int code)
elog(DEBUG3, "shmem_exit(%d): %d on_shmem_exit callbacks to make",
code, on_shmem_exit_index);
while (--on_shmem_exit_index >= 0)
(*on_shmem_exit_list[on_shmem_exit_index].function) (code,
on_shmem_exit_list[on_shmem_exit_index].arg);
on_shmem_exit_list[on_shmem_exit_index].function(code,
on_shmem_exit_list[on_shmem_exit_index].arg);
on_shmem_exit_index = 0;
}

View File

@@ -106,7 +106,7 @@ smgrinit(void)
for (i = 0; i < NSmgr; i++)
{
if (smgrsw[i].smgr_init)
(*(smgrsw[i].smgr_init)) ();
smgrsw[i].smgr_init();
}
/* register the shutdown proc */
@@ -124,7 +124,7 @@ smgrshutdown(int code, Datum arg)
for (i = 0; i < NSmgr; i++)
{
if (smgrsw[i].smgr_shutdown)
(*(smgrsw[i].smgr_shutdown)) ();
smgrsw[i].smgr_shutdown();
}
}
@@ -286,7 +286,7 @@ remove_from_unowned_list(SMgrRelation reln)
bool
smgrexists(SMgrRelation reln, ForkNumber forknum)
{
return (*(smgrsw[reln->smgr_which].smgr_exists)) (reln, forknum);
return smgrsw[reln->smgr_which].smgr_exists(reln, forknum);
}
/*
@@ -299,7 +299,7 @@ smgrclose(SMgrRelation reln)
ForkNumber forknum;
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
(*(smgrsw[reln->smgr_which].smgr_close)) (reln, forknum);
smgrsw[reln->smgr_which].smgr_close(reln, forknum);
owner = reln->smgr_owner;
@@ -395,7 +395,7 @@ smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
reln->smgr_rnode.node.dbNode,
isRedo);
(*(smgrsw[reln->smgr_which].smgr_create)) (reln, forknum, isRedo);
smgrsw[reln->smgr_which].smgr_create(reln, forknum, isRedo);
}
/*
@@ -419,7 +419,7 @@ smgrdounlink(SMgrRelation reln, bool isRedo)
/* Close the forks at smgr level */
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
(*(smgrsw[which].smgr_close)) (reln, forknum);
smgrsw[which].smgr_close(reln, forknum);
/*
* Get rid of any remaining buffers for the relation. bufmgr will just
@@ -451,7 +451,7 @@ smgrdounlink(SMgrRelation reln, bool isRedo)
* ERROR, because we've already decided to commit or abort the current
* xact.
*/
(*(smgrsw[which].smgr_unlink)) (rnode, InvalidForkNumber, isRedo);
smgrsw[which].smgr_unlink(rnode, InvalidForkNumber, isRedo);
}
/*
@@ -491,7 +491,7 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
/* Close the forks at smgr level */
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
(*(smgrsw[which].smgr_close)) (rels[i], forknum);
smgrsw[which].smgr_close(rels[i], forknum);
}
/*
@@ -529,7 +529,7 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
int which = rels[i]->smgr_which;
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
(*(smgrsw[which].smgr_unlink)) (rnodes[i], forknum, isRedo);
smgrsw[which].smgr_unlink(rnodes[i], forknum, isRedo);
}
pfree(rnodes);
@@ -552,7 +552,7 @@ smgrdounlinkfork(SMgrRelation reln, ForkNumber forknum, bool isRedo)
int which = reln->smgr_which;
/* Close the fork at smgr level */
(*(smgrsw[which].smgr_close)) (reln, forknum);
smgrsw[which].smgr_close(reln, forknum);
/*
* Get rid of any remaining buffers for the fork. bufmgr will just drop
@@ -584,7 +584,7 @@ smgrdounlinkfork(SMgrRelation reln, ForkNumber forknum, bool isRedo)
* ERROR, because we've already decided to commit or abort the current
* xact.
*/
(*(smgrsw[which].smgr_unlink)) (rnode, forknum, isRedo);
smgrsw[which].smgr_unlink(rnode, forknum, isRedo);
}
/*
@@ -600,7 +600,7 @@ void
smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
char *buffer, bool skipFsync)
{
(*(smgrsw[reln->smgr_which].smgr_extend)) (reln, forknum, blocknum,
smgrsw[reln->smgr_which].smgr_extend(reln, forknum, blocknum,
buffer, skipFsync);
}
@@ -610,7 +610,7 @@ smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
void
smgrprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum)
{
(*(smgrsw[reln->smgr_which].smgr_prefetch)) (reln, forknum, blocknum);
smgrsw[reln->smgr_which].smgr_prefetch(reln, forknum, blocknum);
}
/*
@@ -625,7 +625,7 @@ void
smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
char *buffer)
{
(*(smgrsw[reln->smgr_which].smgr_read)) (reln, forknum, blocknum, buffer);
smgrsw[reln->smgr_which].smgr_read(reln, forknum, blocknum, buffer);
}
/*
@@ -647,7 +647,7 @@ void
smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
char *buffer, bool skipFsync)
{
(*(smgrsw[reln->smgr_which].smgr_write)) (reln, forknum, blocknum,
smgrsw[reln->smgr_which].smgr_write(reln, forknum, blocknum,
buffer, skipFsync);
}
@@ -660,7 +660,7 @@ void
smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
BlockNumber nblocks)
{
(*(smgrsw[reln->smgr_which].smgr_writeback)) (reln, forknum, blocknum,
smgrsw[reln->smgr_which].smgr_writeback(reln, forknum, blocknum,
nblocks);
}
@@ -671,7 +671,7 @@ smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
BlockNumber
smgrnblocks(SMgrRelation reln, ForkNumber forknum)
{
return (*(smgrsw[reln->smgr_which].smgr_nblocks)) (reln, forknum);
return smgrsw[reln->smgr_which].smgr_nblocks(reln, forknum);
}
/*
@@ -704,7 +704,7 @@ smgrtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
/*
* Do the truncation.
*/
(*(smgrsw[reln->smgr_which].smgr_truncate)) (reln, forknum, nblocks);
smgrsw[reln->smgr_which].smgr_truncate(reln, forknum, nblocks);
}
/*
@@ -733,7 +733,7 @@ smgrtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
void
smgrimmedsync(SMgrRelation reln, ForkNumber forknum)
{
(*(smgrsw[reln->smgr_which].smgr_immedsync)) (reln, forknum);
smgrsw[reln->smgr_which].smgr_immedsync(reln, forknum);
}
@@ -748,7 +748,7 @@ smgrpreckpt(void)
for (i = 0; i < NSmgr; i++)
{
if (smgrsw[i].smgr_pre_ckpt)
(*(smgrsw[i].smgr_pre_ckpt)) ();
smgrsw[i].smgr_pre_ckpt();
}
}
@@ -763,7 +763,7 @@ smgrsync(void)
for (i = 0; i < NSmgr; i++)
{
if (smgrsw[i].smgr_sync)
(*(smgrsw[i].smgr_sync)) ();
smgrsw[i].smgr_sync();
}
}
@@ -778,7 +778,7 @@ smgrpostckpt(void)
for (i = 0; i < NSmgr; i++)
{
if (smgrsw[i].smgr_post_ckpt)
(*(smgrsw[i].smgr_post_ckpt)) ();
smgrsw[i].smgr_post_ckpt();
}
}