From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Neil Conway <neilc(at)samurai(dot)com> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Some new list.c primitives |
Date: | 2005-07-27 22:01:21 |
Message-ID: | 11663.1122501681@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Neil (or anyone else with an opinion),
I'm finding several uses in the planner for some new List primitives
defined as below. I'd like to push these into list.c, but before that,
has anyone got any serious objections? How about suggestions for better
names?
regards, tom lane
/*
* list_add adds the datum to the list if it's not already a member
* (membership is determined by equal()).
*/
static List *
list_add(List *list, void *datum)
{
if (list_member(list, datum))
return list;
else
return lappend(list, datum);
}
/*
* list_add_all does list_add for each element of list2. This is effectively
* the same as list_union(), except that list1 is modified in-place rather
* than being copied.
*/
static List *
list_add_all(List *list1, List *list2)
{
ListCell *cell;
foreach(cell, list2)
{
if (!list_member(list1, lfirst(cell)))
list1 = lappend(list1, lfirst(cell));
}
return list1;
}
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-07-27 22:05:00 | Re: [HACKERS] Autovacuum loose ends |
Previous Message | Simon Riggs | 2005-07-27 22:00:55 | Re: wal_buffer tests in |