MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaH_get

Function luaH_get

freebsd/contrib/openzfs/module/lua/ltable.c:483–506  ·  view source on GitHub ↗

** main search function */

Source from the content-addressed store, hash-verified

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

Callers 5

luaV_gettableFunction · 0.70
luaV_settableFunction · 0.70
luaH_setFunction · 0.70
lua_rawgetFunction · 0.70
lua_rawgetpFunction · 0.70

Calls 3

luaH_getintFunction · 0.85
luaH_getstrFunction · 0.70
mainpositionFunction · 0.70

Tested by

no test coverage detected