diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-08-09 17:58:29 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-08-09 17:58:29 -0300 |
| commit | 92afcf2823e5dfbe9bb10b0ed62306b6015fcfb8 (patch) | |
| tree | 8e360f9491a5d547a8be1aaddce780adb9fcea6b /ltable.c | |
| parent | b5bf7d9ef414ce05da8523b966d94252c32a4010 (diff) | |
| download | lua-github-92afcf2823e5dfbe9bb10b0ed62306b6015fcfb8.tar.gz | |
no more 'luaH_setstr (used only once) + 'luaH_setint' receives value
to be set.
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 24 |
1 files changed, 7 insertions, 17 deletions
@@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.59 2011/06/09 18:23:27 roberto Exp roberto $ +** $Id: ltable.c,v 2.60 2011/06/16 14:14:31 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -314,7 +314,7 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { /* re-insert elements from vanishing slice */ for (i=nasize; i<oldasize; i++) { if (!ttisnil(&t->array[i])) - setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]); + luaH_setint(L, t, i + 1, &t->array[i]); } /* shrink array */ luaM_reallocvector(L, t->array, oldasize, nasize, TValue); @@ -507,27 +507,17 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { } -TValue *luaH_setint (lua_State *L, Table *t, int key) { +void luaH_setint (lua_State *L, Table *t, int key, TValue *value) { const TValue *p = luaH_getint(t, key); + TValue *cell; if (p != luaO_nilobject) - return cast(TValue *, p); + cell = cast(TValue *, p); else { TValue k; setnvalue(&k, cast_num(key)); - return newkey(L, t, &k); - } -} - - -TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { - const TValue *p = luaH_getstr(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else { - TValue k; - setsvalue(L, &k, key); - return newkey(L, t, &k); + cell = newkey(L, t, &k); } + setobj2t(L, cell, value); } |
