From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Andres Freund <andres(at)2ndquadrant(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org, Peter Geoghegan <peter(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)postgresql(dot)org> |
Subject: | Re: embedded list |
Date: | 2012-10-10 03:35:35 |
Message-ID: | 20121010033534.GA11741@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Here's a new version of this patch, updated to STATIC_IF_INLINE. It
addresses most stuff mentioned so far, excepting only the ugly clang
warning in the static assert macros as pointed out by Peter. The
explanatory comment at the top of ilist.h got reformatted a bit and
slightly reworded as well.
The first file, ilist-4.patch, follows the same semantics implemented by
Andres originally: doubly linked lists are always circular, even when
empty. If you apply the second file (ilist-4-circular.patch) on top of
that, you get lists that can be validly initialized to two NULL
pointers. catcache.c gets an example of such lists: instead of calling
dlist_init repeatedly for each cache, we just MemSet() the whole bunch.
I also included two new functions in that patch, dlisti_push_head and
dlisti_push_tail. These functions are identical to dlist_push_head and
dlist_push_tail, except that they do not accept non-circular lists.
What this means is that callers that find the non-circularity acceptable
can use the regular version, and will run dlist_init() on demand;
callers that want the super-tight code can use the other version.
I didn't bother with a new dlist_is_empty.
I imagine both sides will have much to say about this approach. Please
opine.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachment | Content-Type | Size |
---|---|---|
ilist-4.patch | text/x-diff | 74.1 KB |
ilist-4-circular.patch | text/x-diff | 7.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2012-10-10 03:47:07 | Re: Truncate if exists |
Previous Message | Tom Lane | 2012-10-10 02:03:47 | Re: pgxs problem... |