** search function for integers */
| 433 | ** search function for integers |
| 434 | */ |
| 435 | const TValue *luaH_getnum (Table *t, int key) { |
| 436 | /* (1 <= key && key <= t->sizearray) */ |
| 437 | if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) |
| 438 | return &t->array[key-1]; |
| 439 | else { |
| 440 | lua_Number nk = cast_num(key); |
| 441 | Node *n = hashnum(t, nk); |
| 442 | do { /* check whether `key' is somewhere in the chain */ |
| 443 | if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) |
| 444 | return gval(n); /* that's it */ |
| 445 | else n = gnext(n); |
| 446 | } while (n); |
| 447 | return luaO_nilobject; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | |
| 452 | /* |
no test coverage detected