MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sort_comp

Function sort_comp

freebsd/contrib/openzfs/module/lua/ltablib.c:169–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

auxsortFunction · 0.70

Calls 4

lua_callFunction · 0.85
lua_compareFunction · 0.85
lua_pushvalueFunction · 0.70
lua_tobooleanFunction · 0.70

Tested by

no test coverage detected