MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / maxn

Function maxn

third-party/lua-5.2.4/src/ltablib.c:25–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24#if defined(LUA_COMPAT_MAXN)
25static int maxn (lua_State *L) {
26 lua_Number max = 0;
27 luaL_checktype(L, 1, LUA_TTABLE);
28 lua_pushnil(L); /* first key */
29 while (lua_next(L, 1)) {
30 lua_pop(L, 1); /* remove value */
31 if (lua_type(L, -1) == LUA_TNUMBER) {
32 lua_Number v = lua_tonumber(L, -1);
33 if (v > max) max = v;
34 }
35 }
36 lua_pushnumber(L, max);
37 return 1;
38}
39#endif
40
41

Callers

nothing calls this directly

Calls 6

luaL_checktypeFunction · 0.70
lua_pushnilFunction · 0.70
lua_nextFunction · 0.70
lua_typeFunction · 0.70
lua_pushnumberFunction · 0.70
lua_tonumberFunction · 0.50

Tested by

no test coverage detected