commit 94266dfdbd25b43fb84e6dc7752cdb069f0335e9
parent e3871abe95446658383ec3576f473a5f1005736e
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 18 Jun 2014 10:20:47 -0300
source for all prototypes must be equal in a chunk; no need to store
each one separated
Diffstat:
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/ldump.c b/ldump.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldump.c,v 2.28 2014/03/27 15:58:05 roberto Exp roberto $
+** $Id: ldump.c,v 2.29 2014/04/01 14:39:55 roberto Exp roberto $
** save precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -137,7 +137,6 @@ static void DumpUpvalues (const Proto *f, DumpState *D) {
static void DumpDebug (const Proto *f, DumpState *D) {
int i, n;
- DumpString((D->strip) ? NULL : f->source, D);
n = (D->strip) ? 0 : f->sizelineinfo;
DumpInt(n, D);
DumpVector(f->lineinfo, n, D);
@@ -196,6 +195,7 @@ int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data,
D.status = 0;
DumpHeader(&D);
DumpByte(f->sizeupvalues, &D);
+ DumpString((D.strip) ? NULL : f->source, &D);
DumpFunction(f, &D);
return D.status;
}
diff --git a/lundump.c b/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 2.36 2014/04/01 14:39:55 roberto Exp roberto $
+** $Id: lundump.c,v 2.37 2014/04/29 18:14:16 roberto Exp roberto $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -31,6 +31,7 @@ typedef struct {
ZIO *Z;
Mbuffer *b;
const char *name;
+ TString *source; /* source (the same for all prototypes) */
} LoadState;
@@ -167,7 +168,7 @@ static void LoadUpvalues (LoadState *S, Proto *f) {
static void LoadDebug (LoadState *S, Proto *f) {
int i, n;
- f->source = LoadString(S);
+ f->source = S->source;
n = LoadInt(S);
f->lineinfo = luaM_newvector(S->L, n, int);
f->sizelineinfo = n;
@@ -258,6 +259,7 @@ Closure *luaU_undump(lua_State *L, ZIO *Z, Mbuffer *buff,
setclLvalue(L, L->top, cl);
incr_top(L);
cl->l.p = luaF_newproto(L);
+ S.source = cl->l.p->source = LoadString(&S); /* read source */
LoadFunction(&S, cl->l.p);
lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues);
luai_verifycode(L, buff, cl->l.p);