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

Function sort_comp

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

Source from the content-addressed store, hash-verified

169}
170
171static int sort_comp (lua_State *L, int a, int b) {
172 if (!lua_isnil(L, 2)) { /* function? */
173 int res;
174 lua_pushvalue(L, 2);
175 lua_pushvalue(L, a-1); /* -1 to compensate function */
176 lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
177 lua_call(L, 2, 1);
178 res = lua_toboolean(L, -1);
179 lua_pop(L, 1);
180 return res;
181 }
182 else /* a < b? */
183 return lua_compare(L, a, b, LUA_OPLT);
184}
185
186static void auxsort (lua_State *L, int l, int u) {
187 while (l < u) { /* for tail recursion */

Callers 1

auxsortFunction · 0.70

Calls 4

lua_pushvalueFunction · 0.70
lua_tobooleanFunction · 0.70
lua_compareFunction · 0.70
lua_callFunction · 0.50

Tested by

no test coverage detected