From 383e8b9e778d2bed9dc4347f441803e2c4f99d09 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 23 Apr 2002 12:04:39 -0300 Subject: use of a common `dummynode' for all empty tables --- lgc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lgc.c') diff --git a/lgc.c b/lgc.c index f1d00e09..cdfd6496 100644 --- a/lgc.c +++ b/lgc.c @@ -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); -- cgit v1.2.3-55-g6feb