diff options
-rw-r--r-- | lgc.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.148 2002/08/30 19:09:21 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.149 2002/09/02 19:54:49 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 | */ |
@@ -331,15 +331,16 @@ static void sweepstrings (lua_State *L, int all) { | |||
331 | for (i=0; i<G(L)->strt.size; i++) { /* for each list */ | 331 | for (i=0; i<G(L)->strt.size; i++) { /* for each list */ |
332 | G(L)->strt.nuse -= sweeplist(L, &G(L)->strt.hash[i], all); | 332 | G(L)->strt.nuse -= sweeplist(L, &G(L)->strt.hash[i], all); |
333 | } | 333 | } |
334 | if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) && | ||
335 | G(L)->strt.size > MINSTRTABSIZE*2) | ||
336 | luaS_resize(L, G(L)->strt.size/2); /* table is too big */ | ||
337 | } | 334 | } |
338 | 335 | ||
339 | 336 | ||
340 | |||
341 | #define MINBUFFER 256 | 337 | #define MINBUFFER 256 |
342 | static void checkMbuffer (lua_State *L) { | 338 | static void checkSizes (lua_State *L) { |
339 | /* check size of string hash */ | ||
340 | if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) && | ||
341 | G(L)->strt.size > MINSTRTABSIZE*2) | ||
342 | luaS_resize(L, G(L)->strt.size/2); /* table is too big */ | ||
343 | /* check size of buffer */ | ||
343 | if (G(L)->Mbuffsize > MINBUFFER*2) { /* is buffer too big? */ | 344 | if (G(L)->Mbuffsize > MINBUFFER*2) { /* is buffer too big? */ |
344 | size_t newsize = G(L)->Mbuffsize/2; /* still larger than MINBUFFER */ | 345 | size_t newsize = G(L)->Mbuffsize/2; /* still larger than MINBUFFER */ |
345 | luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, newsize, char); | 346 | luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, newsize, char); |
@@ -406,7 +407,7 @@ void luaC_collectgarbage (lua_State *L) { | |||
406 | cleartablevalues(&st); /* again, for eventual weak preserved tables */ | 407 | cleartablevalues(&st); /* again, for eventual weak preserved tables */ |
407 | cleartablekeys(&st); | 408 | cleartablekeys(&st); |
408 | luaC_sweep(L, 0); | 409 | luaC_sweep(L, 0); |
409 | checkMbuffer(L); | 410 | checkSizes(L); |
410 | G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */ | 411 | G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */ |
411 | callGCTM(L); | 412 | callGCTM(L); |
412 | } | 413 | } |