/* returns the index of a 'key' for table traversals. First goes all elements in the array part, then elements in the hash part. The beginning of a traversal is signaled by 0.  */
static unsigned int findindex(lua_State *L, Table *t, TValue *key, unsigned int asize)
/* returns the index of a 'key' for table traversals. First goes all elements in the array part, then elements in the hash part. The beginning of a traversal is signaled by 0.  */
static unsigned int findindex(lua_State *L, Table *t, TValue *key, unsigned int asize)
{
  unsigned int i;
  if (ttisnil(key)) return 0;
  i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0;
  if (i - 1u < asize)
    return i;
  else {
    const TValue *n = getgeneric(t, key, 1);
    if (l_unlikely(isabstkey(n)))
      luaG_runerror(L, "invalid key to 'next'");
    i = cast_int(nodefromval(n) - gnode(t, 0));
    return (i + 1) + asize;
  }
}