aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-01-04 10:54:33 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-01-04 10:54:33 -0200
commitb9c9ccfbb4ed9c6cf6177d20cfd376a0fcb7a959 (patch)
treead23a228be0b4cf74c579652aabae2e1e922dcde
parentb94110a68f0ca5740b5e09c04a8049fd451a2b7a (diff)
downloadlua-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.c12
-rw-r--r--ltable.h3
2 files changed, 13 insertions, 2 deletions
diff --git a/ltable.c b/ltable.c
index 35a7eec8..c875d189 100644
--- a/ltable.c
+++ b/ltable.c
@@ -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
227void 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}
diff --git a/ltable.h b/ltable.h
index b77cf2a2..87a01f83 100644
--- a/ltable.h
+++ b/ltable.h
@@ -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);
22Node *luaH_next (Hash *t, TObject *r); 22Node *luaH_next (Hash *t, TObject *r);
23void luaH_setint (Hash *t, int ref, TObject *val); 23void luaH_setint (Hash *t, int ref, TObject *val);
24TObject *luaH_getint (Hash *t, int ref); 24TObject *luaH_getint (Hash *t, int ref);
25void luaH_move (Hash *t, int from, int to);
25 26
26 27
27#endif 28#endif