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

Function luaH_get_int

lua/ltable.c:543–581  ·  view source on GitHub ↗

** main search function */

Source from the content-addressed store, hash-verified

541** main search function
542*/
543static const TValue *luaH_get_int (Table *t, const TValue *key,
544 TValue **foundkey) {
545 lua_Number num;
546 int type = ttype(key);
547 switch (type) {
548 case LUA_TNIL: return luaO_nilobject;
549 case LUA_TSTRING: return luaH_getstr_int(t, rawtsvalue(key), foundkey);
550 case LUA_TUSERDATA:
551 case LUA_TNUMBER: {
552 int isnum = 1;
553 if (type == LUA_TUSERDATA) {
554 void *raw = rawuvalue(key) + 1; /* lua_topointer */
555 if (luabb_hashinfo(raw, &num, NULL, NULL) != Numeric)
556 isnum = 0;
557 } else {
558 num = nvalue(key);
559 }
560 if (isnum) {
561 int k;
562 lua_number2int(k, num);
563 if (luai_numeq(cast_num(k), num)) /* index is int? */
564 return luaH_getnum_int(t, k, foundkey); /* use specialized version */
565 }
566 /* else go through */
567 }
568 default: {
569 Node *n = mainposition(t, key);
570 do { /* check whether `key' is somewhere in the chain */
571 if (luaO_rawequalObj(key2tval(n), key)) {
572 if (foundkey)
573 *foundkey = key2tval(n);
574 return gval(n); /* that's it */
575 }
576 n = gnext(n);
577 } while (n);
578 return luaO_nilobject;
579 }
580 }
581}
582
583
584const TValue *luaH_get(Table *t, const TValue *key) {

Callers 2

luaH_getFunction · 0.85
luaH_set_intFunction · 0.85

Calls 5

luaH_getstr_intFunction · 0.85
luabb_hashinfoFunction · 0.85
luaH_getnum_intFunction · 0.85
mainpositionFunction · 0.85
luaO_rawequalObjFunction · 0.85

Tested by

no test coverage detected