aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-01-05 16:20:51 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-01-05 16:20:51 -0200
commite2498e079e4636217e89f0b28844c4b5df4f8793 (patch)
treeda82e007f0e8153985323c2bdb190811f79e0c57 /lgc.c
parent65726f3e2e226f6a350a5dba643c13c8edd34965 (diff)
downloadlua-e2498e079e4636217e89f0b28844c4b5df4f8793.tar.gz
lua-e2498e079e4636217e89f0b28844c4b5df4f8793.tar.bz2
lua-e2498e079e4636217e89f0b28844c4b5df4f8793.zip
change in hash algorithm so that it does not need empty slot
(tables can be 100% full)
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lgc.c b/lgc.c
index f401505c..0d76d2b1 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.18 2004/12/06 17:53:42 roberto Exp roberto $ 2** $Id: lgc.c,v 2.19 2004/12/13 12:15:11 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -63,7 +63,7 @@
63 63
64 64
65static void removeentry (Node *n) { 65static void removeentry (Node *n) {
66 setnilvalue(gval(n)); /* remove corresponding value ... */ 66 lua_assert(ttisnil(gval(n)));
67 if (iscollectable(gkey(n))) 67 if (iscollectable(gkey(n)))
68 setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ 68 setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
69} 69}
@@ -162,7 +162,6 @@ static int traversetable (global_State *g, Table *h) {
162 const TValue *mode; 162 const TValue *mode;
163 if (h->metatable) 163 if (h->metatable)
164 markobject(g, h->metatable); 164 markobject(g, h->metatable);
165 lua_assert(h->lsizenode || h->node == g->dummynode);
166 mode = gfasttm(g, h->metatable, TM_MODE); 165 mode = gfasttm(g, h->metatable, TM_MODE);
167 if (mode && ttisstring(mode)) { /* is there a weak mode? */ 166 if (mode && ttisstring(mode)) { /* is there a weak mode? */
168 weakkey = (strchr(svalue(mode), 'k') != NULL); 167 weakkey = (strchr(svalue(mode), 'k') != NULL);
@@ -368,8 +367,10 @@ static void cleartable (GCObject *l) {
368 while (i--) { 367 while (i--) {
369 Node *n = gnode(h, i); 368 Node *n = gnode(h, i);
370 if (!ttisnil(gval(n)) && /* non-empty entry? */ 369 if (!ttisnil(gval(n)) && /* non-empty entry? */
371 (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) 370 (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
371 setnilvalue(gval(n)); /* remove value ... */
372 removeentry(n); /* remove entry from table */ 372 removeentry(n); /* remove entry from table */
373 }
373 } 374 }
374 l = h->gclist; 375 l = h->gclist;
375 } 376 }