macro 'key2tal' replaced by 'gkey' (as both were equal)

This commit is contained in:
Roberto Ierusalimschy 2010-06-25 09:18:10 -03:00
parent ca3865cf1b
commit d9ea6eca7c
4 changed files with 13 additions and 15 deletions

6
lgc.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 2.98 2010/06/04 13:25:10 roberto Exp roberto $ ** $Id: lgc.c,v 2.99 2010/06/07 16:55:34 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -371,7 +371,7 @@ static int traverseephemeron (global_State *g, Table *h) {
if (ttisnil(gval(n))) /* entry is empty? */ if (ttisnil(gval(n))) /* entry is empty? */
removeentry(n); /* remove it */ removeentry(n); /* remove it */
else if (valiswhite(gval(n))) { /* value not marked yet? */ else if (valiswhite(gval(n))) { /* value not marked yet? */
if (iscleared(key2tval(n), 1)) /* key is not marked (yet)? */ if (iscleared(gkey(n), 1)) /* key is not marked (yet)? */
hasclears = 1; /* may have to propagate mark from key to value */ hasclears = 1; /* may have to propagate mark from key to value */
else { /* key is marked, so mark value */ else { /* key is marked, so mark value */
marked = 1; /* value was not marked */ marked = 1; /* value was not marked */
@ -574,7 +574,7 @@ static void cleartable (GCObject *l) {
} }
for (n = gnode(h, 0); n < limit; n++) { for (n = gnode(h, 0); n < limit; n++) {
if (!ttisnil(gval(n)) && /* non-empty entry? */ if (!ttisnil(gval(n)) && /* non-empty entry? */
(iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { (iscleared(gkey(n), 1) || iscleared(gval(n), 0))) {
setnilvalue(gval(n)); /* remove value ... */ setnilvalue(gval(n)); /* remove value ... */
removeentry(n); /* and remove entry from table */ removeentry(n); /* and remove entry from table */
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltable.c,v 2.50 2010/04/18 13:22:48 roberto Exp roberto $ ** $Id: ltable.c,v 2.51 2010/06/04 13:05:29 roberto Exp roberto $
** Lua tables (hash) ** Lua tables (hash)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -148,7 +148,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
Node *n = mainposition(t, key); Node *n = mainposition(t, key);
do { /* check whether `key' is somewhere in the chain */ do { /* check whether `key' is somewhere in the chain */
/* key may be dead already, but it is ok to use it in `next' */ /* key may be dead already, but it is ok to use it in `next' */
if (luaO_rawequalObj(key2tval(n), key) || if (luaO_rawequalObj(gkey(n), key) ||
(ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
gcvalue(gkey(n)) == gcvalue(key))) { gcvalue(gkey(n)) == gcvalue(key))) {
i = cast_int(n - gnode(t, 0)); /* key index in hash table */ i = cast_int(n - gnode(t, 0)); /* key index in hash table */
@ -174,7 +174,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
} }
for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
setobj2s(L, key, key2tval(gnode(t, i))); setobj2s(L, key, gkey(gnode(t, i)));
setobj2s(L, key+1, gval(gnode(t, i))); setobj2s(L, key+1, gval(gnode(t, i)));
return 1; return 1;
} }
@ -255,7 +255,7 @@ static int numusehash (const Table *t, int *nums, int *pnasize) {
while (i--) { while (i--) {
Node *n = &t->node[i]; Node *n = &t->node[i];
if (!ttisnil(gval(n))) { if (!ttisnil(gval(n))) {
ause += countint(key2tval(n), nums); ause += countint(gkey(n), nums);
totaluse++; totaluse++;
} }
} }
@ -321,7 +321,7 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
for (i = twoto(oldhsize) - 1; i >= 0; i--) { for (i = twoto(oldhsize) - 1; i >= 0; i--) {
Node *old = nold+i; Node *old = nold+i;
if (!ttisnil(gval(old))) if (!ttisnil(gval(old)))
setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
} }
if (!isdummy(nold)) if (!isdummy(nold))
luaM_freearray(L, nold, twoto(oldhsize)); /* free old array */ luaM_freearray(L, nold, twoto(oldhsize)); /* free old array */
@ -406,7 +406,7 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
return luaH_set(L, t, key); /* re-insert key into grown table */ return luaH_set(L, t, key); /* re-insert key into grown table */
} }
lua_assert(!isdummy(n)); lua_assert(!isdummy(n));
othern = mainposition(t, key2tval(mp)); othern = mainposition(t, gkey(mp));
if (othern != mp) { /* is colliding node out of its main position? */ if (othern != mp) { /* is colliding node out of its main position? */
/* yes; move colliding node into free position */ /* yes; move colliding node into free position */
while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
@ -481,7 +481,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
default: { default: {
Node *n = mainposition(t, key); Node *n = mainposition(t, key);
do { /* check whether `key' is somewhere in the chain */ do { /* check whether `key' is somewhere in the chain */
if (luaO_rawequalObj(key2tval(n), key)) if (luaO_rawequalObj(gkey(n), key))
return gval(n); /* that's it */ return gval(n); /* that's it */
else n = gnext(n); else n = gnext(n);
} while (n); } while (n);

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltable.h,v 2.12 2009/08/07 16:17:41 roberto Exp roberto $ ** $Id: ltable.h,v 2.13 2009/11/06 17:07:48 roberto Exp roberto $
** Lua tables (hash) ** Lua tables (hash)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -15,8 +15,6 @@
#define gval(n) (&(n)->i_val) #define gval(n) (&(n)->i_val)
#define gnext(n) ((n)->i_key.nk.next) #define gnext(n) ((n)->i_key.nk.next)
#define key2tval(n) (&(n)->i_key.tvk)
LUAI_FUNC const TValue *luaH_getint (Table *t, int key); LUAI_FUNC const TValue *luaH_getint (Table *t, int key);
LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, int key); LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, int key);

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltests.c,v 2.108 2010/05/17 20:10:17 roberto Exp roberto $ ** $Id: ltests.c,v 2.109 2010/06/10 21:29:47 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation ** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -689,7 +689,7 @@ static int table_query (lua_State *L) {
if (!ttisnil(gval(gnode(t, i))) || if (!ttisnil(gval(gnode(t, i))) ||
ttisnil(gkey(gnode(t, i))) || ttisnil(gkey(gnode(t, i))) ||
ttisnumber(gkey(gnode(t, i)))) { ttisnumber(gkey(gnode(t, i)))) {
pushobject(L, key2tval(gnode(t, i))); pushobject(L, gkey(gnode(t, i)));
} }
else else
lua_pushliteral(L, "<undef>"); lua_pushliteral(L, "<undef>");