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

Function sort_comp

deps/lua/src/ltablib.c:178–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178static int sort_comp (lua_State *L, int a, int b) {
179 if (!lua_isnil(L, 2)) { /* function? */
180 int res;
181 lua_pushvalue(L, 2);
182 lua_pushvalue(L, a-1); /* -1 to compensate function */
183 lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
184 lua_call(L, 2, 1);
185 res = lua_toboolean(L, -1);
186 lua_pop(L, 1);
187 return res;
188 }
189 else /* a < b? */
190 return lua_lessthan(L, a, b);
191}
192
193static void auxsort (lua_State *L, int l, int u) {
194 while (l < u) { /* for tail recursion */

Callers 1

auxsortFunction · 0.85

Calls 4

lua_pushvalueFunction · 0.85
lua_callFunction · 0.85
lua_tobooleanFunction · 0.85
lua_lessthanFunction · 0.85

Tested by

no test coverage detected