mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +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:
@@ -159,7 +159,7 @@ MemoryContextResetOnly(MemoryContext context)
|
||||
if (!context->isReset)
|
||||
{
|
||||
MemoryContextCallResetCallbacks(context);
|
||||
(*context->methods->reset) (context);
|
||||
context->methods->reset(context);
|
||||
context->isReset = true;
|
||||
VALGRIND_DESTROY_MEMPOOL(context);
|
||||
VALGRIND_CREATE_MEMPOOL(context, 0, false);
|
||||
@@ -222,7 +222,7 @@ MemoryContextDelete(MemoryContext context)
|
||||
*/
|
||||
MemoryContextSetParent(context, NULL);
|
||||
|
||||
(*context->methods->delete_context) (context);
|
||||
context->methods->delete_context(context);
|
||||
VALGRIND_DESTROY_MEMPOOL(context);
|
||||
pfree(context);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ MemoryContextCallResetCallbacks(MemoryContext context)
|
||||
while ((cb = context->reset_cbs) != NULL)
|
||||
{
|
||||
context->reset_cbs = cb->next;
|
||||
(*cb->func) (cb->arg);
|
||||
cb->func(cb->arg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,8 +391,7 @@ GetMemoryChunkSpace(void *pointer)
|
||||
{
|
||||
MemoryContext context = GetMemoryChunkContext(pointer);
|
||||
|
||||
return (context->methods->get_chunk_space) (context,
|
||||
pointer);
|
||||
return context->methods->get_chunk_space(context, pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -423,7 +422,7 @@ MemoryContextIsEmpty(MemoryContext context)
|
||||
if (context->firstchild != NULL)
|
||||
return false;
|
||||
/* Otherwise use the type-specific inquiry */
|
||||
return (*context->methods->is_empty) (context);
|
||||
return context->methods->is_empty(context);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -481,7 +480,7 @@ MemoryContextStatsInternal(MemoryContext context, int level,
|
||||
AssertArg(MemoryContextIsValid(context));
|
||||
|
||||
/* Examine the context itself */
|
||||
(*context->methods->stats) (context, level, print, totals);
|
||||
context->methods->stats(context, level, print, totals);
|
||||
|
||||
/*
|
||||
* Examine children. If there are more than max_children of them, we do
|
||||
@@ -546,7 +545,7 @@ MemoryContextCheck(MemoryContext context)
|
||||
|
||||
AssertArg(MemoryContextIsValid(context));
|
||||
|
||||
(*context->methods->check) (context);
|
||||
context->methods->check(context);
|
||||
for (child = context->firstchild; child != NULL; child = child->nextchild)
|
||||
MemoryContextCheck(child);
|
||||
}
|
||||
@@ -675,7 +674,7 @@ MemoryContextCreate(NodeTag tag, Size size,
|
||||
strcpy(node->name, name);
|
||||
|
||||
/* Type-specific routine finishes any other essential initialization */
|
||||
(*node->methods->init) (node);
|
||||
node->methods->init(node);
|
||||
|
||||
/* OK to link node to parent (if any) */
|
||||
/* Could use MemoryContextSetParent here, but doesn't seem worthwhile */
|
||||
@@ -716,7 +715,7 @@ MemoryContextAlloc(MemoryContext context, Size size)
|
||||
|
||||
context->isReset = false;
|
||||
|
||||
ret = (*context->methods->alloc) (context, size);
|
||||
ret = context->methods->alloc(context, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -751,7 +750,7 @@ MemoryContextAllocZero(MemoryContext context, Size size)
|
||||
|
||||
context->isReset = false;
|
||||
|
||||
ret = (*context->methods->alloc) (context, size);
|
||||
ret = context->methods->alloc(context, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -788,7 +787,7 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
|
||||
|
||||
context->isReset = false;
|
||||
|
||||
ret = (*context->methods->alloc) (context, size);
|
||||
ret = context->methods->alloc(context, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -823,7 +822,7 @@ MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
|
||||
|
||||
context->isReset = false;
|
||||
|
||||
ret = (*context->methods->alloc) (context, size);
|
||||
ret = context->methods->alloc(context, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((flags & MCXT_ALLOC_NO_OOM) == 0)
|
||||
@@ -859,7 +858,7 @@ palloc(Size size)
|
||||
|
||||
CurrentMemoryContext->isReset = false;
|
||||
|
||||
ret = (*CurrentMemoryContext->methods->alloc) (CurrentMemoryContext, size);
|
||||
ret = CurrentMemoryContext->methods->alloc(CurrentMemoryContext, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -888,7 +887,7 @@ palloc0(Size size)
|
||||
|
||||
CurrentMemoryContext->isReset = false;
|
||||
|
||||
ret = (*CurrentMemoryContext->methods->alloc) (CurrentMemoryContext, size);
|
||||
ret = CurrentMemoryContext->methods->alloc(CurrentMemoryContext, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -920,7 +919,7 @@ palloc_extended(Size size, int flags)
|
||||
|
||||
CurrentMemoryContext->isReset = false;
|
||||
|
||||
ret = (*CurrentMemoryContext->methods->alloc) (CurrentMemoryContext, size);
|
||||
ret = CurrentMemoryContext->methods->alloc(CurrentMemoryContext, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((flags & MCXT_ALLOC_NO_OOM) == 0)
|
||||
@@ -951,7 +950,7 @@ pfree(void *pointer)
|
||||
{
|
||||
MemoryContext context = GetMemoryChunkContext(pointer);
|
||||
|
||||
(*context->methods->free_p) (context, pointer);
|
||||
context->methods->free_p(context, pointer);
|
||||
VALGRIND_MEMPOOL_FREE(context, pointer);
|
||||
}
|
||||
|
||||
@@ -973,7 +972,7 @@ repalloc(void *pointer, Size size)
|
||||
/* isReset must be false already */
|
||||
Assert(!context->isReset);
|
||||
|
||||
ret = (*context->methods->realloc) (context, pointer, size);
|
||||
ret = context->methods->realloc(context, pointer, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -1007,7 +1006,7 @@ MemoryContextAllocHuge(MemoryContext context, Size size)
|
||||
|
||||
context->isReset = false;
|
||||
|
||||
ret = (*context->methods->alloc) (context, size);
|
||||
ret = context->methods->alloc(context, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
@@ -1041,7 +1040,7 @@ repalloc_huge(void *pointer, Size size)
|
||||
/* isReset must be false already */
|
||||
Assert(!context->isReset);
|
||||
|
||||
ret = (*context->methods->realloc) (context, pointer, size);
|
||||
ret = context->methods->realloc(context, pointer, size);
|
||||
if (ret == NULL)
|
||||
{
|
||||
MemoryContextStats(TopMemoryContext);
|
||||
|
||||
Reference in New Issue
Block a user