use of a common `dummynode' for all empty tables

This commit is contained in:
Roberto Ierusalimschy
2002-04-23 12:04:39 -03:00
parent f1a1bb23fe
commit 383e8b9e77
4 changed files with 46 additions and 35 deletions

15
lgc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 1.133 2002/03/26 18:55:50 roberto Exp roberto $
** $Id: lgc.c,v 1.134 2002/04/05 18:54:31 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -211,14 +211,13 @@ static void traversetable (GCState *st, Table *h) {
int weakkey = 0;
int weakvalue = 0;
marktable(st, h->metatable);
lua_assert(h->lsizenode || h->node == G(st->L)->dummynode);
mode = fasttm(st->L, h->metatable, TM_WEAKMODE);
if (mode) { /* weak table? must be cleared after GC... */
h->mark = st->toclear; /* put in the appropriate list */
st->toclear = h;
if (ttype(mode) == LUA_TSTRING) {
weakkey = (strchr(svalue(mode), 'k') != NULL);
weakvalue = (strchr(svalue(mode), 'v') != NULL);
}
if (mode && ttype(mode) == LUA_TSTRING) { /* weak table? */
h->mark = st->toclear; /* must be cleared after GC, ... */
st->toclear = h; /* ...put in the appropriate list */
weakkey = (strchr(svalue(mode), 'k') != NULL);
weakvalue = (strchr(svalue(mode), 'v') != NULL);
}
if (!weakvalue) {
i = sizearray(h);