Adding doubly linked list type which stores the number of items in the list
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2022-10-27T03:35:26Z
Lists: pgsql-hackers
Attachments
- v1-0001-Add-doubly-linked-count-list-implementation.patch (text/plain) patch v1-0001
As part of the AIO work [1], there are quite a number of dlist_heads which a counter is used to keep track on how many items are in the list. We also have a few places in master which do the same thing. In order to tidy this up and to help ensure that the count variable does not get out of sync with the items which are stored in the list, how about we introduce "dclist" which maintains the count for us? I've attached a patch which does this. The majority of the functions for the new type are just wrappers around the equivalent dlist function. dclist provides all of the functionality that dlist does except there's no dclist_delete() function. dlist_delete() can be done by just knowing the element to delete and not the list that the element belongs to. With dclist, that's not possible as we must also subtract 1 from the count variable and obviously we need the dclist_head for that. I'll add this to the November commitfest. David [1] https://www.postgresql.org/message-id/flat/20210223100344.llw5an2aklengrmn@alap3.anarazel.de
Commits
-
Add doubly linked count list implementation
- 7c335b7a2027 16.0 landed