diff options
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 24 |
1 files changed, 7 insertions, 17 deletions
| @@ -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 | ||
| 510 | TValue *luaH_setint (lua_State *L, Table *t, int key) { | 510 | void 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 | |||
| 522 | TValue *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 | ||
