pgsql: Improve ilist.h's support for deletion of slist elements during

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve ilist.h's support for deletion of slist elements during
Date: 2013-07-24 21:42:58
Message-ID: E1V26pm-0003Xk-NE@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve ilist.h's support for deletion of slist elements during iteration.

Previously one had to use slist_delete(), implying an additional scan of
the list, making this infrastructure considerably less efficient than
traditional Lists when deletion of element(s) in a long list is needed.
Modify the slist_foreach_modify() macro to support deleting the current
element in O(1) time, by keeping a "prev" pointer in addition to "cur"
and "next". Although this makes iteration with this macro a bit slower,
no real harm is done, since in any scenario where you're not going to
delete the current list element you might as well just use slist_foreach
instead. Improve the comments about when to use each macro.

Back-patch to 9.3 so that we'll have consistent semantics in all branches
that provide ilist.h. Note this is an ABI break for callers of
slist_foreach_modify().

Andres Freund and Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/fa2fad3c06bfde03594ff38d53acdf9a60c56bb2

Modified Files
--------------
src/backend/lib/ilist.c | 2 +-
src/backend/postmaster/bgworker.c | 15 ++++---
src/backend/postmaster/pgstat.c | 7 +++
src/backend/postmaster/postmaster.c | 4 +-
src/include/lib/ilist.h | 62 ++++++++++++++++++++++-----
src/include/postmaster/bgworker_internals.h | 2 +-
6 files changed, 72 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Stephen Frost 2013-07-24 23:03:24 pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL
Previous Message Bruce Momjian 2013-07-24 17:15:54 pgsql: pg_upgrade: more Windows parallel/-j fixes