static void rehash(Hash *t) { int32 nold = nhash(t); Node *vold = nodevector(t); int32 i; if (!emptyslots(t)) nhash(t) = luaO_redimension(nhash(t)); nodevector(t) = hashnodecreate(nhash(t)); for (i = 0; i < nold; i++) { Node *n = vold + i; if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL) *node(t, present(t, ref(n))) = *n; // copy old node to luaM_new hash } nblocks += gcsize(t->nhash) - gcsize(nold); luaM_free(vold); }
static void rehash (Hash *t) { int nold = nhash(t); Node *vold = nodevector(t); int i; if (!emptyslots(t)) nhash(t) = luaI_redimension(nhash(t)); nodevector(t) = hashnodecreate(nhash(t)); for (i=0; i<nold; i++) { Node *n = vold+i; if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL) *node(t, present(t, ref(n))) = *n; /* copy old node to new hash */ } luaI_free(vold); }