diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-01-04 10:54:33 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-01-04 10:54:33 -0200 |
commit | b9c9ccfbb4ed9c6cf6177d20cfd376a0fcb7a959 (patch) | |
tree | ad23a228be0b4cf74c579652aabae2e1e922dcde | |
parent | b94110a68f0ca5740b5e09c04a8049fd451a2b7a (diff) | |
download | lua-b9c9ccfbb4ed9c6cf6177d20cfd376a0fcb7a959.tar.gz lua-b9c9ccfbb4ed9c6cf6177d20cfd376a0fcb7a959.tar.bz2 lua-b9c9ccfbb4ed9c6cf6177d20cfd376a0fcb7a959.zip |
function "move" for tables is better implemented with some "inside
information".
-rw-r--r-- | ltable.c | 12 | ||||
-rw-r--r-- | ltable.h | 3 |
2 files changed, 13 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.15 1998/08/11 16:38:34 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.16 1998/12/30 13:14:46 roberto Exp $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -223,3 +223,13 @@ TObject *luaH_getint (Hash *t, int ref) { | |||
223 | return luaH_get(t, &index); | 223 | return luaH_get(t, &index); |
224 | } | 224 | } |
225 | 225 | ||
226 | |||
227 | void luaH_move (Hash *t, int from, int to) { | ||
228 | TObject index; | ||
229 | TObject *toadd; | ||
230 | ttype(&index) = LUA_T_NUMBER; | ||
231 | nvalue(&index) = to; | ||
232 | toadd = luaH_set(t, &index); | ||
233 | nvalue(&index) = from; | ||
234 | *toadd = *luaH_get(t, &index); | ||
235 | } | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.h,v 1.6 1998/07/12 16:15:19 roberto Exp roberto $ | 2 | ** $Id: ltable.h,v 1.7 1998/12/30 13:14:46 roberto Exp $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -22,6 +22,7 @@ TObject *luaH_set (Hash *t, TObject *ref); | |||
22 | Node *luaH_next (Hash *t, TObject *r); | 22 | Node *luaH_next (Hash *t, TObject *r); |
23 | void luaH_setint (Hash *t, int ref, TObject *val); | 23 | void luaH_setint (Hash *t, int ref, TObject *val); |
24 | TObject *luaH_getint (Hash *t, int ref); | 24 | TObject *luaH_getint (Hash *t, int ref); |
25 | void luaH_move (Hash *t, int from, int to); | ||
25 | 26 | ||
26 | 27 | ||
27 | #endif | 28 | #endif |