Some new list.c primitives - Mailing list pgsql-hackers

From Tom Lane
Subject Some new list.c primitives
Date
Msg-id 11663.1122501681@sss.pgh.pa.us
Whole thread Raw
Responses Re: Some new list.c primitives  (Gavin Sherry <swm@linuxworld.com.au>)
Re: Some new list.c primitives  (David Fetter <david@fetter.org>)
List 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
list1is 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;
}


pgsql-hackers by date:

Previous
From: Mark Wong
Date:
Subject: Re: wal_buffer tests in
Next
From: Simon Riggs
Date:
Subject: Re: wal_buffer tests in