Tom Lane wrote:
> "Heikki Linnakangas" <heikki@enterprisedb.com> writes:
>> Note that the MemSetLoop macro used in palloc0fast is supposed to be
>> evaluated at compile time,
>
> Oooh, good point, I had forgotten about that little detail. Yeah,
> we'll lose that optimization if we move the code out-of-line.
Well, we could still have the MemSetTest outside the function, and
evaluated at compile-time, if we provided an aligned and unaligned
version of newNode:
#define newNode(size, tag) \
( \AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \( MemSetTest(0, sz) ? \
newNodeAligned(CurrentMemoryContext,sz, tag) : \ newNodeNotAligned(CurrentMemoryContext, sz, tag))
And if you're worried about the function call overhead,
newNode(Not)Aligned could have the contents of MemoryContextAllocZero
inlined into it. Not sure how much optimization is worthwhile here..
-- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com