mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
Simplify newNode() by removing special cases
- Remove MemoryContextAllocZeroAligned(). It was supposed to be a faster version of MemoryContextAllocZero(), but modern compilers turn the MemSetLoop() into a call to memset() anyway, making it more or less identical to MemoryContextAllocZero(). That was the only user of MemSetTest, MemSetLoop, so remove those too, as well as palloc0fast(). - Convert newNode() to a static inline function. When this was originally originally written, it was written as a macro because testing showed that gcc didn't inline the size check as we intended. Modern compiler versions do, and now that it just calls palloc0() there is no size-check to inline anyway. One nice effect is that the palloc0() takes one less argument than MemoryContextAllocZeroAligned(), which saves a few instructions in the callers of newNode(). Reviewed-by: Peter Eisentraut, Tom Lane, John Naylor, Thomas Munro Discussion: https://www.postgresql.org/message-id/b51f1fa7-7e6a-4ecc-936d-90a8a1659e7c@iki.fi
This commit is contained in:
@@ -23,7 +23,6 @@ OBJS = \
|
||||
makefuncs.o \
|
||||
multibitmapset.o \
|
||||
nodeFuncs.o \
|
||||
nodes.o \
|
||||
outfuncs.o \
|
||||
params.o \
|
||||
print.o \
|
||||
|
||||
@@ -7,7 +7,6 @@ backend_sources += files(
|
||||
'makefuncs.c',
|
||||
'multibitmapset.c',
|
||||
'nodeFuncs.c',
|
||||
'nodes.c',
|
||||
'params.c',
|
||||
'print.c',
|
||||
'read.c',
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* nodes.c
|
||||
* support code for nodes (now that we have removed the home-brew
|
||||
* inheritance system, our support code for nodes is much simpler)
|
||||
*
|
||||
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* src/backend/nodes/nodes.c
|
||||
*
|
||||
* HISTORY
|
||||
* Andrew Yu Oct 20, 1994 file creation
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "nodes/nodes.h"
|
||||
|
||||
/*
|
||||
* Support for newNode() macro
|
||||
*
|
||||
* In a GCC build there is no need for the global variable newNodeMacroHolder.
|
||||
* However, we create it anyway, to support the case of a non-GCC-built
|
||||
* loadable module being loaded into a GCC-built backend.
|
||||
*/
|
||||
|
||||
Node *newNodeMacroHolder;
|
||||
Reference in New Issue
Block a user