aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-08 15:46:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-08 15:46:08 -0300
commitb3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4 (patch)
tree746fc9900768dfaf1ddffca35cb4f6fd55903bbf /ldo.c
parent02afc892d5ce5d85e88faac443d7294589ee697a (diff)
downloadlua-b3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4.tar.gz
lua-b3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4.tar.bz2
lua-b3d0682fb94f56a438dbb4fdb2b3440ccc10cfb4.zip
use of different buffers for scanner and concatenation
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ldo.c b/ldo.c
index a0772421..27688d2d 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.193 2002/08/30 19:09:21 roberto Exp roberto $ 2** $Id: ldo.c,v 1.194 2002/09/02 20:00:41 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -420,12 +420,13 @@ int luaD_pcall (lua_State *L, int nargs, int nresults, ptrdiff_t errfunc) {
420*/ 420*/
421struct SParser { /* data to `f_parser' */ 421struct SParser { /* data to `f_parser' */
422 ZIO *z; 422 ZIO *z;
423 Mbuffer buff; /* buffer to be used by the scanner */
423 int bin; 424 int bin;
424}; 425};
425 426
426static void f_parser (lua_State *L, void *ud) { 427static void f_parser (lua_State *L, void *ud) {
427 struct SParser *p = cast(struct SParser *, ud); 428 struct SParser *p = cast(struct SParser *, ud);
428 Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z); 429 Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z, &p->buff);
429 Closure *cl = luaF_newLclosure(L, 0, gt(L)); 430 Closure *cl = luaF_newLclosure(L, 0, gt(L));
430 cl->l.p = tf; 431 cl->l.p = tf;
431 setclvalue(L->top, cl); 432 setclvalue(L->top, cl);
@@ -439,11 +440,13 @@ int luaD_protectedparser (lua_State *L, ZIO *z, int bin) {
439 int status; 440 int status;
440 ptrdiff_t oldtopr = savestack(L, L->top); /* save current top */ 441 ptrdiff_t oldtopr = savestack(L, L->top); /* save current top */
441 p.z = z; p.bin = bin; 442 p.z = z; p.bin = bin;
443 luaZ_initbuffer(L, &p.buff);
442 /* before parsing, give a (good) chance to GC */ 444 /* before parsing, give a (good) chance to GC */
443 if (G(L)->nblocks + G(L)->nblocks/4 >= G(L)->GCthreshold) 445 if (G(L)->nblocks + G(L)->nblocks/4 >= G(L)->GCthreshold)
444 luaC_collectgarbage(L); 446 luaC_collectgarbage(L);
445 old_blocks = G(L)->nblocks; 447 old_blocks = G(L)->nblocks;
446 status = luaD_rawrunprotected(L, f_parser, &p); 448 status = luaD_rawrunprotected(L, f_parser, &p);
449 luaZ_freebuffer(L, &p.buff);
447 if (status == 0) { 450 if (status == 0) {
448 /* add new memory to threshold (as it probably will stay) */ 451 /* add new memory to threshold (as it probably will stay) */
449 lua_assert(G(L)->nblocks >= old_blocks); 452 lua_assert(G(L)->nblocks >= old_blocks);