aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-08-09 17:58:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-08-09 17:58:29 -0300
commit92afcf2823e5dfbe9bb10b0ed62306b6015fcfb8 (patch)
tree8e360f9491a5d547a8be1aaddce780adb9fcea6b /ltable.c
parentb5bf7d9ef414ce05da8523b966d94252c32a4010 (diff)
downloadlua-92afcf2823e5dfbe9bb10b0ed62306b6015fcfb8.tar.gz
lua-92afcf2823e5dfbe9bb10b0ed62306b6015fcfb8.tar.bz2
lua-92afcf2823e5dfbe9bb10b0ed62306b6015fcfb8.zip
no more 'luaH_setstr (used only once) + 'luaH_setint' receives value
to be set.
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/ltable.c b/ltable.c
index 9abf47eb..b2f40083 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.59 2011/06/09 18:23:27 roberto Exp roberto $ 2** $Id: ltable.c,v 2.60 2011/06/16 14:14:31 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -314,7 +314,7 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
314 /* re-insert elements from vanishing slice */ 314 /* re-insert elements from vanishing slice */
315 for (i=nasize; i<oldasize; i++) { 315 for (i=nasize; i<oldasize; i++) {
316 if (!ttisnil(&t->array[i])) 316 if (!ttisnil(&t->array[i]))
317 setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]); 317 luaH_setint(L, t, i + 1, &t->array[i]);
318 } 318 }
319 /* shrink array */ 319 /* shrink array */
320 luaM_reallocvector(L, t->array, oldasize, nasize, TValue); 320 luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
@@ -507,27 +507,17 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
507} 507}
508 508
509 509
510TValue *luaH_setint (lua_State *L, Table *t, int key) { 510void luaH_setint (lua_State *L, Table *t, int key, TValue *value) {
511 const TValue *p = luaH_getint(t, key); 511 const TValue *p = luaH_getint(t, key);
512 TValue *cell;
512 if (p != luaO_nilobject) 513 if (p != luaO_nilobject)
513 return cast(TValue *, p); 514 cell = cast(TValue *, p);
514 else { 515 else {
515 TValue k; 516 TValue k;
516 setnvalue(&k, cast_num(key)); 517 setnvalue(&k, cast_num(key));
517 return newkey(L, t, &k); 518 cell = newkey(L, t, &k);
518 }
519}
520
521
522TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
523 const TValue *p = luaH_getstr(t, key);
524 if (p != luaO_nilobject)
525 return cast(TValue *, p);
526 else {
527 TValue k;
528 setsvalue(L, &k, key);
529 return newkey(L, t, &k);
530 } 519 }
520 setobj2t(L, cell, value);
531} 521}
532 522
533 523