From ba0f38d6018a20214c2a6b48cba0e1400a9b91bf Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 1 Jun 2004 06:02:13 +0000 Subject: [PATCH] FastList is history, yay. --- src/backend/nodes/list.c | 83 +++------------------------------------------ src/include/nodes/pg_list.h | 55 +++++++++++------------------- 2 files changed, 24 insertions(+), 114 deletions(-) diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index f6843707df..94c69a5425 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -9,13 +9,15 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.58 2004/05/30 23:40:27 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.59 2004/06/01 06:02:12 tgl Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" + #include "nodes/pg_list.h" + /* * Routines to simplify writing assertions about the type of a list; a * NIL list is considered to be an empty list of any type. @@ -1069,7 +1071,7 @@ list_length(List *l) * * In order to avoid warnings for these function definitions, we need * to include a prototype here as well as in pg_list.h. That's because - * we explicitly disable list API compatibility in list.c, so we + * we don't enable list API compatibility in list.c, so we * don't see the prototypes for these functions. */ @@ -1087,80 +1089,3 @@ length(List *list) { return list_length(list); } - -/* - * This code implements the old "Fast List" API, making use of the new - * List code to do so. There's no need for FastList anymore, so this - * code is a bit sloppy -- it will be removed soon. - */ -void FastListInit(FastList *fl); - -void -FastListInit(FastList *fl) -{ - fl->list = NIL; -} - -void FastListFromList(FastList *fl, List *l); - -void -FastListFromList(FastList *fl, List *list) -{ - fl->list = list; -} - -List *FastListValue(FastList *fl); - -List * -FastListValue(FastList *fl) -{ - return fl->list; -} - -void makeFastList1(FastList *fl, void *elem); - -void -makeFastList1(FastList *fl, void *elem) -{ - fl->list = list_make1(elem); -} - -void FastAppend(FastList *fl, void *datum); - -void -FastAppend(FastList *fl, void *datum) -{ - fl->list = lappend(fl->list, datum); -} - -void FastAppendi(FastList *fl, int datum); - -void -FastAppendi(FastList *fl, int datum) -{ - fl->list = lappend_int(fl->list, datum); -} - -void FastAppendo(FastList *fl, Oid datum); - -void -FastAppendo(FastList *fl, Oid datum) -{ - fl->list = lappend_oid(fl->list, datum); -} - -void FastConc(FastList *fl, List *cells); - -void -FastConc(FastList *fl, List *cells) -{ - fl->list = list_concat(fl->list, cells); -} - -void FastConcFast(FastList *fl1, FastList *fl2); - -void -FastConcFast(FastList *fl1, FastList *fl2) -{ - fl1->list = list_concat(fl1->list, fl2->list); -} diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index 9394f22439..9b0d16cfc7 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -3,22 +3,9 @@ * pg_list.h * interface for PostgreSQL generic linked list package * + * This package implements singly-linked homogeneous lists. * - * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.46 2004/05/30 23:40:39 neilc Exp $ - * - *------------------------------------------------------------------------- - */ -#ifndef PG_LIST_H -#define PG_LIST_H - -#include "nodes/nodes.h" - -/* - * This package implements singly-linked homogeneous lists. It is - * important to have constant-time length, append, and prepend + * It is important to have constant-time length, append, and prepend * operations. To achieve this, we deal with two distinct data * structures: * @@ -38,7 +25,20 @@ * * (At the moment, ints and Oids are the same size, but they may not * always be so; try to be careful to maintain the distinction.) + * + * + * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.47 2004/06/01 06:02:13 tgl Exp $ + * + *------------------------------------------------------------------------- */ +#ifndef PG_LIST_H +#define PG_LIST_H + +#include "nodes/nodes.h" + typedef struct ListCell ListCell; @@ -107,7 +107,7 @@ extern int list_length(List *l); * the List API: the macro lfirst() was used to mean "the data in this * cons cell". To avoid changing every usage of lfirst(), that meaning * has been kept. As a result, lfirst() takes a ListCell and returns - * the data it contains; to get the data in the _first_ cell of a + * the data it contains; to get the data in the first cell of a * List, use linitial(). Worse, lsecond() is more closely related to * linitial() than lfirst(): given a List, lsecond() returns the data * in the second cons cell. @@ -122,10 +122,6 @@ extern int list_length(List *l); #define linitial_int(l) lfirst_int(list_head(l)) #define linitial_oid(l) lfirst_oid(list_head(l)) -#define llast(l) lfirst(list_tail(l)) -#define llast_int(l) lfirst_int(list_tail(l)) -#define llast_oid(l) lfirst_oid(list_tail(l)) - #define lsecond(l) lfirst(lnext(list_head(l))) #define lsecond_int(l) lfirst_int(lnext(list_head(l))) #define lsecond_oid(l) lfirst_oid(lnext(list_head(l))) @@ -138,6 +134,10 @@ extern int list_length(List *l); #define lfourth_int(l) lfirst_int(lnext(lnext(lnext(list_head(l))))) #define lfourth_oid(l) lfirst_oid(lnext(lnext(lnext(list_head(l))))) +#define llast(l) lfirst(list_tail(l)) +#define llast_int(l) lfirst_int(list_tail(l)) +#define llast_oid(l) lfirst_oid(list_tail(l)) + /* * Convenience macros for building fixed-length lists */ @@ -301,19 +301,4 @@ extern int length(List *list); #endif /* ENABLE_LIST_COMPAT */ -typedef struct FastList -{ - List *list; -} FastList; - -extern void FastListInit(FastList *fl); -extern void FastListFromList(FastList *fl, List *list); -extern List *FastListValue(FastList *fl); -extern void makeFastList1(FastList *fl, void *elem); -extern void FastAppend(FastList *fl, void *datum); -extern void FastAppendi(FastList *fl, int datum); -extern void FastAppendo(FastList *fl, Oid datum); -extern void FastConc(FastList *fl, List *cells); -extern void FastConcFast(FastList *fl1, FastList *fl2); - #endif /* PG_LIST_H */ -- 2.11.0