Browse Source

configurable minimum size for the string table

v5-2
Roberto Ierusalimschy 23 years ago
parent
commit
457d88eaaa
  1. 4
      lgc.c
  2. 7
      llimits.h
  3. 4
      lstate.c

4
lgc.c

@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 1.127 2002/01/30 17:26:44 roberto Exp roberto $ ** $Id: lgc.c,v 1.128 2002/03/04 21:32:34 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -366,7 +366,7 @@ static void collectstrings (lua_State *L, int all) {
} }
} }
if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) && if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) &&
G(L)->strt.size > 4) G(L)->strt.size > MINSTRTABSIZE*2)
luaS_resize(L, G(L)->strt.size/2); /* table is too big */ luaS_resize(L, G(L)->strt.size/2); /* table is too big */
} }

7
llimits.h

@ -1,5 +1,5 @@
/* /*
** $Id: llimits.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ ** $Id: llimits.h,v 1.37 2002/02/14 21:43:01 roberto Exp roberto $
** Limits, basic types, and some other `installation-dependent' definitions ** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -108,5 +108,10 @@ typedef unsigned long Instruction;
#endif #endif
/* minimum size for the string table */
#ifndef MINSTRTABSIZE
#define MINSTRTABSIZE 20
#endif
#endif #endif

4
lstate.c

@ -1,5 +1,5 @@
/* /*
** $Id: lstate.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ ** $Id: lstate.c,v 1.84 2002/02/14 21:40:13 roberto Exp roberto $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -65,7 +65,7 @@ static void f_luaopen (lua_State *L, void *ud) {
hvalue(defaultmeta(L))->metatable = hvalue(defaultmeta(L)); hvalue(defaultmeta(L))->metatable = hvalue(defaultmeta(L));
sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */ sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */
sethvalue(registry(L), luaH_new(L, 0, 0)); /* registry */ sethvalue(registry(L), luaH_new(L, 0, 0)); /* registry */
luaS_resize(L, 4); /* initial size of string table */ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
luaT_init(L); luaT_init(L);
luaX_init(L); luaX_init(L);
G(L)->GCthreshold = 4*G(L)->nblocks; G(L)->GCthreshold = 4*G(L)->nblocks;

Loading…
Cancel
Save