浏览代码

there is no need for a size for Cblocks

Roberto Ierusalimschy 26 年之前
父节点
当前提交
705eae9fe4
共有 3 个文件被更改,包括 12 次插入23 次删除
  1. 10 19
      lapi.c
  2. 1 2
      lstate.c
  3. 1 2
      lstate.h

+ 10 - 19
lapi.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 1.42 1999/03/26 13:14:00 roberto Exp roberto $
+** $Id: lapi.c,v 1.43 1999/05/11 14:19:32 roberto Exp roberto $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -167,15 +167,12 @@ lua_Object lua_gettable (void)
 }
 
 
-lua_Object lua_rawgettable (void)
-{
+lua_Object lua_rawgettable (void) {
   checkCparams(2);
   if (ttype(L->stack.top-2) != LUA_T_ARRAY)
     lua_error("indexed expression not a table in rawgettable");
-  else {
-    *(L->stack.top-2) = *luaH_get(avalue(L->stack.top-2), L->stack.top-1);
-    --L->stack.top;
-  }
+  *(L->stack.top-2) = *luaH_get(avalue(L->stack.top-2), L->stack.top-1);
+  --L->stack.top;
   return put_luaObjectonTop();
 }
 
@@ -368,14 +365,11 @@ void luaA_pushobject (TObject *o)
   incr_top;
 }
 
-void lua_pushobject (lua_Object o)
-{
+void lua_pushobject (lua_Object o) {
   if (o == LUA_NOOBJECT)
     lua_error("API error - attempt to push a NOOBJECT");
-  else {
-    set_normalized(L->stack.top, Address(o));
-    incr_top;
-  }
+  set_normalized(L->stack.top, Address(o));
+  incr_top;
 }
 
 
@@ -638,16 +632,13 @@ char *lua_getobjname (lua_Object o, char **name)
 
 
 #ifndef	MAX_C_BLOCKS
-#define MAX_C_BLOCKS	500
+#define MAX_C_BLOCKS	1000
 #endif
 
 
 void lua_beginblock (void) {
-  if (L->numCblocks >= L->sizeCblocks) {
-    luaM_growvector(L->Cblocks, L->numCblocks, 1, struct C_Lua_Stack,
-                    "too many nested blocks", MAX_C_BLOCKS);
-    L->sizeCblocks++;
-  }
+  luaM_growvector(L->Cblocks, L->numCblocks, 1, struct C_Lua_Stack,
+                  "too many nested blocks", MAX_C_BLOCKS);
   L->Cblocks[L->numCblocks] = L->Cstack;
   L->numCblocks++;
 }

+ 1 - 2
lstate.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.c,v 1.10 1999/04/13 19:30:51 roberto Exp roberto $
+** $Id: lstate.c,v 1.11 1999/05/11 14:19:32 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -33,7 +33,6 @@ void lua_open (void)
   L->Mbuffsize = 0;
   L->Mbuffnext = 0;
   L->Cblocks = NULL;
-  L->sizeCblocks = 0;
   L->numCblocks = 0;
   L->debug = 0;
   L->callhook = NULL;

+ 1 - 2
lstate.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.h,v 1.17 1999/05/10 13:54:01 roberto Exp roberto $
+** $Id: lstate.h,v 1.18 1999/05/11 14:19:32 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -68,7 +68,6 @@ struct lua_State {
   int Mbuffsize;  /* size of Mbuffer */
   int Mbuffnext;  /* next position to fill in Mbuffer */
   struct C_Lua_Stack *Cblocks;
-  int sizeCblocks;  /* size of Cblocks */
   int numCblocks;  /* number of nested Cblocks */
   int debug;
   lua_CHFunction callhook;