aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-09-27 04:12:03 +0000
committerNeil Conway <neilc@samurai.com>2004-09-27 04:12:03 +0000
commit64a60590ba5da8026abb65a7abe8fce9e573c476 (patch)
treefbb640591745e267977b99289e25e6ef4694fb08 /src/backend/utils/cache
parent0ed07d49d5b5aed54da02b9dfa87856ba09af859 (diff)
downloadpostgresql-64a60590ba5da8026abb65a7abe8fce9e573c476.tar.gz
postgresql-64a60590ba5da8026abb65a7abe8fce9e573c476.zip
A few minor list-related cleanups:
(1) Replace while loop with the new forboth() construct in parser/analyze.c (2) Replace lcons() with lappend() in SearchCatCacheList(). Since these now have the same performance, there is no reason to prefer lcons() in this case, and using lappend() leads to cleaner code. (3) Improve the name of the second parameter to for_each_cell()
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r--src/backend/utils/cache/catcache.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index b66007c0693..0a11411e9a9 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.116 2004/08/29 05:06:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.117 2004/09/27 04:12:02 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1501,7 +1501,7 @@ SearchCatCacheList(CatCache *cache,
* worth fixing.
*/
ct->refcount++;
- ctlist = lcons(ct, ctlist);
+ ctlist = lappend(ctlist, ct);
nmembers++;
}
@@ -1522,16 +1522,17 @@ SearchCatCacheList(CatCache *cache,
cl->cl_magic = CL_MAGIC;
cl->my_cache = cache;
- DLInitElem(&cl->cache_elem, (void *) cl);
+ DLInitElem(&cl->cache_elem, cl);
cl->refcount = 0; /* for the moment */
cl->dead = false;
cl->ordered = ordered;
cl->nkeys = nkeys;
cl->hash_value = lHashValue;
cl->n_members = nmembers;
- /* The list is backwards because we built it with lcons */
+
+ Assert(nmembers == list_length(ctlist));
ctlist_item = list_head(ctlist);
- for (i = nmembers; --i >= 0;)
+ for (i = 0; i < nmembers; i++)
{
cl->members[i] = ct = (CatCTup *) lfirst(ctlist_item);
Assert(ct->c_list == NULL);