From 94266dfdbd25b43fb84e6dc7752cdb069f0335e9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 18 Jun 2014 10:21:12 -0300 Subject: [PATCH] source for all prototypes must be equal in a chunk; no need to store each one separated --- ldump.c | 4 ++-- lundump.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ldump.c b/ldump.c index 3d39e6bd..cb07aa17 100644 --- 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 index b0c31c78..ffc8853b 100644 --- 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);