** main search function */
| 479 | ** main search function |
| 480 | */ |
| 481 | const TValue *luaH_get (Table *t, const TValue *key) { |
| 482 | switch (ttype(key)) { |
| 483 | case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); |
| 484 | case LUA_TNIL: return luaO_nilobject; |
| 485 | case LUA_TNUMBER: { |
| 486 | int k; |
| 487 | lua_Number n = nvalue(key); |
| 488 | lua_number2int(k, n); |
| 489 | if (luai_numeq(cast_num(k), n)) /* index is int? */ |
| 490 | return luaH_getint(t, k); /* use specialized version */ |
| 491 | /* else go through */ |
| 492 | } |
| 493 | default: { |
| 494 | Node *n = mainposition(t, key); |
| 495 | do { /* check whether `key' is somewhere in the chain */ |
| 496 | if (luaV_rawequalobj(gkey(n), key)) |
| 497 | return gval(n); /* that's it */ |
| 498 | else n = gnext(n); |
| 499 | } while (n); |
| 500 | return luaO_nilobject; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | |
| 506 | /* |
no test coverage detected