Re: Is it really such a good thing for newNode() to be a macro?
От | Heikki Linnakangas |
---|---|
Тема | Re: Is it really such a good thing for newNode() to be a macro? |
Дата | |
Msg-id | 48B5656D.6010909@enterprisedb.com обсуждение исходный текст |
Ответ на | Re: Is it really such a good thing for newNode() to be a macro? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Is it really such a good thing for newNode() to be a macro?
|
Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: