Ver Fonte

macro 'incr_top' replaced by function 'luaD_inctop'. (It is not used
in critical time pathes, can save a few bytes without the macro)

Roberto Ierusalimschy há 9 anos atrás
pai
commit
8c1fb91802
5 ficheiros alterados com 24 adições e 11 exclusões
  1. 14 1
      ldo.c
  2. 2 2
      ldo.h
  3. 3 3
      lobject.c
  4. 3 3
      lparser.c
  5. 2 2
      lundump.c

+ 14 - 1
ldo.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 2.145 2015/11/02 11:48:59 roberto Exp roberto $
+** $Id: ldo.c,v 2.146 2015/11/02 14:06:01 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -150,6 +150,11 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
 /* }====================================================== */
 
 
+/*
+** {==================================================================
+** Stack reallocation
+** ===================================================================
+*/
 static void correctstack (lua_State *L, TValue *oldstack) {
   CallInfo *ci;
   UpVal *up;
@@ -229,6 +234,14 @@ void luaD_shrinkstack (lua_State *L) {
 }
 
 
+void luaD_inctop (lua_State *L) {
+  luaD_checkstack(L, 1);
+  L->top++;
+}
+
+/* }================================================================== */
+
+
 void luaD_hook (lua_State *L, int event, int line) {
   lua_Hook hook = L->hook;
   if (hook && L->allowhook) {

+ 2 - 2
ldo.h

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.h,v 2.22 2015/05/22 17:48:19 roberto Exp roberto $
+** $Id: ldo.h,v 2.23 2015/10/21 18:40:47 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -28,7 +28,6 @@
 #define luaD_checkstack(L,n)	luaD_checkstackaux(L,n,,)
 
 
-#define incr_top(L) {L->top++; luaD_checkstack(L,0);}
 
 #define savestack(L,p)		((char *)(p) - (char *)L->stack)
 #define restorestack(L,n)	((TValue *)((char *)L->stack + (n)))
@@ -49,6 +48,7 @@ LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult, int nres);
 LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
 LUAI_FUNC void luaD_growstack (lua_State *L, int n);
 LUAI_FUNC void luaD_shrinkstack (lua_State *L);
+LUAI_FUNC void luaD_inctop (lua_State *L);
 
 LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
 LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);

+ 3 - 3
lobject.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lobject.c,v 2.106 2015/06/26 19:32:07 roberto Exp roberto $
+** $Id: lobject.c,v 2.107 2015/11/02 14:02:35 roberto Exp roberto $
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 */
@@ -347,7 +347,7 @@ void luaO_tostring (lua_State *L, StkId obj) {
 
 static void pushstr (lua_State *L, const char *str, size_t l) {
   setsvalue2s(L, L->top, luaS_newlstr(L, str, l));
-  incr_top(L);
+  luaD_inctop(L);
 }
 
 
@@ -385,7 +385,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
       case 'f': {
         setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
       top2str:
-        incr_top(L);
+        luaD_inctop(L);
         luaO_tostring(L, L->top - 1);
         break;
       }

+ 3 - 3
lparser.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp roberto $
+** $Id: lparser.c,v 2.148 2015/10/28 17:28:40 roberto Exp roberto $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -1627,10 +1627,10 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
   FuncState funcstate;
   LClosure *cl = luaF_newLclosure(L, 1);  /* create main closure */
   setclLvalue(L, L->top, cl);  /* anchor it (to avoid being collected) */
-  incr_top(L);
+  luaD_inctop(L);
   lexstate.h = luaH_new(L);  /* create table for scanner */
   sethvalue(L, L->top, lexstate.h);  /* anchor it */
-  incr_top(L);
+  luaD_inctop(L);
   funcstate.f = cl->p = luaF_newproto(L);
   funcstate.f->source = luaS_new(L, name);  /* create and anchor TString */
   lua_assert(iswhite(funcstate.f));  /* do not need barrier here */

+ 2 - 2
lundump.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.c,v 2.42 2015/09/08 15:41:05 roberto Exp roberto $
+** $Id: lundump.c,v 2.43 2015/09/17 15:51:05 roberto Exp roberto $
 ** load precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -269,7 +269,7 @@ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) {
   checkHeader(&S);
   cl = luaF_newLclosure(L, LoadByte(&S));
   setclLvalue(L, L->top, cl);
-  incr_top(L);
+  luaD_inctop(L);
   cl->p = luaF_newproto(L);
   LoadFunction(&S, cl->p, NULL);
   lua_assert(cl->nupvalues == cl->p->sizeupvalues);