MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaH_getint

Function luaH_getint

extlibs/lua/src/ltable.c:683–705  ·  view source on GitHub ↗

** Search function for integers. If integer is inside 'alimit', get it ** directly from the array part. Otherwise, if 'alimit' is not equal to ** the real size of the array, key still can be in the array part. In ** this case, try to avoid a call to 'luaH_realasize' when key is just ** one more than the limit (so that it can be incremented without ** changing the real size of the array). */

Source from the content-addressed store, hash-verified

681** changing the real size of the array).
682*/
683const TValue *luaH_getint (Table *t, lua_Integer key) {
684 if (l_castS2U(key) - 1u < t->alimit) /* 'key' in [1, t->alimit]? */
685 return &t->array[key - 1];
686 else if (!limitequalsasize(t) && /* key still may be in the array part? */
687 (l_castS2U(key) == t->alimit + 1 ||
688 l_castS2U(key) - 1u < luaH_realasize(t))) {
689 t->alimit = cast_uint(key); /* probably '#t' is here now */
690 return &t->array[key - 1];
691 }
692 else {
693 Node *n = hashint(t, key);
694 for (;;) { /* check whether 'key' is somewhere in the chain */
695 if (keyisinteger(n) && keyival(n) == key)
696 return gval(n); /* that's it */
697 else {
698 int nx = gnext(n);
699 if (nx == 0) break;
700 n += nx;
701 }
702 }
703 return &absentkey;
704 }
705}
706
707
708/*

Callers 8

luaH_getFunction · 0.85
luaH_setintFunction · 0.85
hash_searchFunction · 0.85
luaH_getnFunction · 0.85
lua_getglobalFunction · 0.85
lua_rawgetiFunction · 0.85
lua_setglobalFunction · 0.85
lua_loadFunction · 0.85

Calls 1

luaH_realasizeFunction · 0.85

Tested by

no test coverage detected