MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaH_getnum_int

Function luaH_getnum_int

lua/ltable.c:468–499  ·  view source on GitHub ↗

** search function for integers */

Source from the content-addressed store, hash-verified

466** search function for integers
467*/
468static const TValue *luaH_getnum_int (Table *t, int key,
469 TValue **foundkey) {
470 /* (1 <= key && key <= t->sizearray) */
471 if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) {
472 if (foundkey)
473 *foundkey = NULL;
474 return &t->array[key-1];
475 }
476
477 int found = 0;
478 lua_Number nk = cast_num(key);
479 Node *n = hashnum(t, nk);
480 do { /* check whether `key' is somewhere in the chain */
481 if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) {
482 found = 1;
483 } else if (ttisuserdata(gkey(n))) {
484 double d;
485 void *udata = rawuvalue(gkey(n)) + 1;
486 if (luabb_hashinfo(udata, &d, NULL, NULL) == Numeric
487 && luai_numeq(d, nk)) {
488 found = 1;
489 }
490 }
491 if (found) {
492 if (foundkey)
493 *foundkey = key2tval(n);
494 return gval(n); /* that's it */
495 }
496 n = gnext(n);
497 } while (n);
498 return luaO_nilobject;
499}
500
501
502const TValue *luaH_getnum (Table *t, int key) {

Callers 2

luaH_getnumFunction · 0.85
luaH_get_intFunction · 0.85

Calls 2

hashnumFunction · 0.85
luabb_hashinfoFunction · 0.85

Tested by

no test coverage detected