aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ltable.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/ltable.c b/ltable.c
index 67194a8e..8c00deec 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.3 2004/04/30 20:13:38 roberto Exp roberto $ 2** $Id: ltable.c,v 2.4 2004/08/10 19:17:23 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*/
@@ -394,21 +394,6 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
394 394
395 395
396/* 396/*
397** generic search function
398*/
399static const TValue *luaH_getany (Table *t, const TValue *key) {
400 if (!ttisnil(key)) {
401 Node *n = luaH_mainposition(t, key);
402 do { /* check whether `key' is somewhere in the chain */
403 if (luaO_rawequalObj(gkey(n), key)) return gval(n); /* that's it */
404 else n = n->next;
405 } while (n);
406 }
407 return &luaO_nilobject;
408}
409
410
411/*
412** search function for integers 397** search function for integers
413*/ 398*/
414const TValue *luaH_getnum (Table *t, int key) { 399const TValue *luaH_getnum (Table *t, int key) {
@@ -446,6 +431,7 @@ const TValue *luaH_getstr (Table *t, TString *key) {
446*/ 431*/
447const TValue *luaH_get (Table *t, const TValue *key) { 432const TValue *luaH_get (Table *t, const TValue *key) {
448 switch (ttype(key)) { 433 switch (ttype(key)) {
434 case LUA_TNIL: return &luaO_nilobject;
449 case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); 435 case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
450 case LUA_TNUMBER: { 436 case LUA_TNUMBER: {
451 int k; 437 int k;
@@ -454,7 +440,14 @@ const TValue *luaH_get (Table *t, const TValue *key) {
454 return luaH_getnum(t, k); /* use specialized version */ 440 return luaH_getnum(t, k); /* use specialized version */
455 /* else go through */ 441 /* else go through */
456 } 442 }
457 default: return luaH_getany(t, key); 443 default: {
444 Node *n = luaH_mainposition(t, key);
445 do { /* check whether `key' is somewhere in the chain */
446 if (luaO_rawequalObj(gkey(n), key)) return gval(n); /* that's it */
447 else n = n->next;
448 } while (n);
449 return &luaO_nilobject;
450 }
458 } 451 }
459} 452}
460 453