MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaH_get

Function luaH_get

deps/lua/src/ltable.c:469–491  ·  view source on GitHub ↗

** main search function */

Source from the content-addressed store, hash-verified

467** main search function
468*/
469const TValue *luaH_get (Table *t, const TValue *key) {
470 switch (ttype(key)) {
471 case LUA_TNIL: return luaO_nilobject;
472 case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
473 case LUA_TNUMBER: {
474 int k;
475 lua_Number n = nvalue(key);
476 lua_number2int(k, n);
477 if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
478 return luaH_getnum(t, k); /* use specialized version */
479 /* else go through */
480 }
481 default: {
482 Node *n = mainposition(t, key);
483 do { /* check whether `key' is somewhere in the chain */
484 if (luaO_rawequalObj(key2tval(n), key))
485 return gval(n); /* that's it */
486 else n = gnext(n);
487 } while (n);
488 return luaO_nilobject;
489 }
490 }
491}
492
493
494TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {

Callers 3

luaV_gettableFunction · 0.85
luaH_setFunction · 0.85
lua_rawgetFunction · 0.85

Calls 4

luaH_getstrFunction · 0.85
luaH_getnumFunction · 0.85
mainpositionFunction · 0.85
luaO_rawequalObjFunction · 0.85

Tested by

no test coverage detected