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

Function maxn

deps/lua/src/ltablib.c:56–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56static int maxn (lua_State *L) {
57 lua_Number max = 0;
58 luaL_checktype(L, 1, LUA_TTABLE);
59 lua_pushnil(L); /* first key */
60 while (lua_next(L, 1)) {
61 lua_pop(L, 1); /* remove value */
62 if (lua_type(L, -1) == LUA_TNUMBER) {
63 lua_Number v = lua_tonumber(L, -1);
64 if (v > max) max = v;
65 }
66 }
67 lua_pushnumber(L, max);
68 return 1;
69}
70
71
72static int getn (lua_State *L) {

Callers

nothing calls this directly

Calls 6

luaL_checktypeFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_typeFunction · 0.85
lua_tonumberFunction · 0.85
lua_pushnumberFunction · 0.85

Tested by

no test coverage detected