2
0
Roberto Ierusalimschy 25 жил өмнө
parent
commit
b803c0600e
2 өөрчлөгдсөн 10 нэмэгдсэн , 17 устгасан
  1. 4 4
      lgc.c
  2. 6 13
      ltable.c

+ 4 - 4
lgc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.c,v 1.48 2000/05/08 19:32:53 roberto Exp roberto $
+** $Id: lgc.c,v 1.49 2000/05/10 16:33:20 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -62,7 +62,7 @@ static void closuremark (lua_State *L, Closure *f) {
 }
 }
 
 
 
 
-static void hashmark (lua_State *L, Hash *h) {
+static void tablemark (lua_State *L, Hash *h) {
   if (!h->marked) {
   if (!h->marked) {
     int i;
     int i;
     h->marked = 1;
     h->marked = 1;
@@ -99,7 +99,7 @@ static int markobject (lua_State *L, TObject *o) {
       strmark(L, tsvalue(o));
       strmark(L, tsvalue(o));
       break;
       break;
     case TAG_TABLE:
     case TAG_TABLE:
-      hashmark(L, avalue(o));
+      tablemark(L, avalue(o));
       break;
       break;
     case TAG_LCLOSURE:  case TAG_LMARK:
     case TAG_LCLOSURE:  case TAG_LMARK:
       protomark(L, clvalue(o)->f.l);
       protomark(L, clvalue(o)->f.l);
@@ -206,7 +206,7 @@ static void collectstring (lua_State *L, int limit) {
 
 
 static void markall (lua_State *L) {
 static void markall (lua_State *L) {
   travstack(L); /* mark stack objects */
   travstack(L); /* mark stack objects */
-  hashmark(L, L->gt);  /* mark global variable values and names */
+  tablemark(L, L->gt);  /* mark global variable values and names */
   travlock(L); /* mark locked objects */
   travlock(L); /* mark locked objects */
   luaT_travtagmethods(L, markobject);  /* mark tag methods */
   luaT_travtagmethods(L, markobject);  /* mark tag methods */
 }
 }

+ 6 - 13
ltable.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltable.c,v 1.40 2000/04/25 16:55:09 roberto Exp roberto $
+** $Id: ltable.c,v 1.41 2000/05/08 19:32:53 roberto Exp roberto $
 ** Lua tables (hash)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -122,20 +122,13 @@ int luaH_pos (lua_State *L, const Hash *t, const TObject *key) {
 }
 }
 
 
 
 
-
-static Node *hashnodecreate (lua_State *L, int nhash) {
-  Node *v = luaM_newvector(L, nhash, Node);
+static void setnodevector (lua_State *L, Hash *t, int size) {
   int i;
   int i;
-  for (i=0; i<nhash; i++) {
-    ttype(&v[i].key) = ttype(&v[i].val) = TAG_NIL;
-    v[i].next = NULL;
+  t->node = luaM_newvector(L, size, Node);
+  for (i=0; i<size; i++) {
+    ttype(&t->node[i].key) = ttype(&t->node[i].val) = TAG_NIL;
+    t->node[i].next = NULL;
   }
   }
-  return v;
-}
-
-
-static void setnodevector (lua_State *L, Hash *t, int size) {
-  t->node = hashnodecreate(L, size);
   t->size = size;
   t->size = size;
   t->firstfree = &t->node[size-1];  /* first free position to be used */
   t->firstfree = &t->node[size-1];  /* first free position to be used */
   L->nblocks += gcsize(L, size);
   L->nblocks += gcsize(L, size);