diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-06-04 10:25:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-06-04 10:25:10 -0300 |
commit | 575074fd857b90cd7c14c7b172e8fe147080962a (patch) | |
tree | 6929e87845a56266061235f89213795806ee5291 /lfunc.c | |
parent | 545f43065ff8fa20e5f8254e6270d00694b847dd (diff) | |
download | lua-575074fd857b90cd7c14c7b172e8fe147080962a.tar.gz lua-575074fd857b90cd7c14c7b172e8fe147080962a.tar.bz2 lua-575074fd857b90cd7c14c7b172e8fe147080962a.zip |
Lua closures are cached for reuse
Diffstat (limited to 'lfunc.c')
-rw-r--r-- | lfunc.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 2.23 2010/04/29 21:43:36 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.24 2010/05/10 18:23:45 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -29,9 +29,11 @@ Closure *luaF_newCclosure (lua_State *L, int n) { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
32 | Closure *luaF_newLclosure (lua_State *L, int n) { | 32 | Closure *luaF_newLclosure (lua_State *L, Proto *p) { |
33 | int n = p->sizeupvalues; | ||
33 | Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeLclosure(n), NULL, 0)->cl; | 34 | Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeLclosure(n), NULL, 0)->cl; |
34 | c->l.isC = 0; | 35 | c->l.isC = 0; |
36 | c->l.p = p; | ||
35 | c->l.nupvalues = cast_byte(n); | 37 | c->l.nupvalues = cast_byte(n); |
36 | while (n--) c->l.upvals[n] = NULL; | 38 | while (n--) c->l.upvals[n] = NULL; |
37 | return c; | 39 | return c; |
@@ -116,6 +118,7 @@ Proto *luaF_newproto (lua_State *L) { | |||
116 | f->p = NULL; | 118 | f->p = NULL; |
117 | f->sizep = 0; | 119 | f->sizep = 0; |
118 | f->code = NULL; | 120 | f->code = NULL; |
121 | f->cache = NULL; | ||
119 | f->sizecode = 0; | 122 | f->sizecode = 0; |
120 | f->lineinfo = NULL; | 123 | f->lineinfo = NULL; |
121 | f->sizelineinfo = 0; | 124 | f->sizelineinfo = 0; |