aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-22 14:58:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-22 14:58:14 -0300
commit81bc5711a8b71ced34eef8750deb0ce4475d5cd5 (patch)
tree452e7c82585045989f041cb78c0fcdb7cdd5f724 /lstate.c
parent6a77a6b73f0f06c4396e9b60d44b064b999cb06a (diff)
downloadlua-81bc5711a8b71ced34eef8750deb0ce4475d5cd5.tar.gz
lua-81bc5711a8b71ced34eef8750deb0ce4475d5cd5.tar.bz2
lua-81bc5711a8b71ced34eef8750deb0ce4475d5cd5.zip
only one instance of registry and default metatable per global state
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lstate.c b/lstate.c
index a8136d1a..58631289 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.105 2002/08/30 19:09:21 roberto Exp roberto $ 2** $Id: lstate.c,v 1.106 2002/10/08 18:46:08 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -25,7 +25,7 @@ static void close_state (lua_State *L);
25 25
26 26
27/* 27/*
28** you can change this function through the official API 28** you can change this function through the official API:
29** call `lua_setpanicf' 29** call `lua_setpanicf'
30*/ 30*/
31static int default_panic (lua_State *L) { 31static int default_panic (lua_State *L) {
@@ -61,6 +61,8 @@ static void f_luaopen (lua_State *L, void *ud) {
61 G(L)->strt.size = 0; 61 G(L)->strt.size = 0;
62 G(L)->strt.nuse = 0; 62 G(L)->strt.nuse = 0;
63 G(L)->strt.hash = NULL; 63 G(L)->strt.hash = NULL;
64 setnilvalue(defaultmeta(L));
65 setnilvalue(registry(L));
64 luaZ_initbuffer(L, &G(L)->buff); 66 luaZ_initbuffer(L, &G(L)->buff);
65 G(L)->panic = &default_panic; 67 G(L)->panic = &default_panic;
66 G(L)->rootgc = NULL; 68 G(L)->rootgc = NULL;
@@ -97,9 +99,7 @@ static void preinit_state (lua_State *L) {
97 L->size_ci = 0; 99 L->size_ci = 0;
98 L->base_ci = L->ci = NULL; 100 L->base_ci = L->ci = NULL;
99 L->errfunc = 0; 101 L->errfunc = 0;
100 setnilvalue(defaultmeta(L));
101 setnilvalue(gt(L)); 102 setnilvalue(gt(L));
102 setnilvalue(registry(L));
103} 103}
104 104
105 105
@@ -114,9 +114,7 @@ LUA_API lua_State *lua_newthread (lua_State *OL) {
114 OL->next = L; 114 OL->next = L;
115 L->previous = OL; 115 L->previous = OL;
116 stack_init(L, OL); /* init stack */ 116 stack_init(L, OL); /* init stack */
117 setobj(defaultmeta(L), defaultmeta(OL)); /* share default meta table */
118 setobj(gt(L), gt(OL)); /* share table of globals */ 117 setobj(gt(L), gt(OL)); /* share table of globals */
119 setobj(registry(L), registry(OL)); /* share registry */
120 lua_unlock(OL); 118 lua_unlock(OL);
121 lua_userstateopen(L); 119 lua_userstateopen(L);
122 return L; 120 return L;