diff options
-rw-r--r-- | ltablib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -298,14 +298,14 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) { | |||
298 | for (;;) { | 298 | for (;;) { |
299 | /* next loop: repeat ++i while a[i] < P */ | 299 | /* next loop: repeat ++i while a[i] < P */ |
300 | while ((void)geti(L, 1, ++i), sort_comp(L, -1, -2)) { | 300 | while ((void)geti(L, 1, ++i), sort_comp(L, -1, -2)) { |
301 | if (l_unlikely(i == up - 1)) /* a[i] < P but a[up - 1] == P ?? */ | 301 | if (l_unlikely(i == up - 1)) /* a[up - 1] < P == a[up - 1] */ |
302 | luaL_error(L, "invalid order function for sorting"); | 302 | luaL_error(L, "invalid order function for sorting"); |
303 | lua_pop(L, 1); /* remove a[i] */ | 303 | lua_pop(L, 1); /* remove a[i] */ |
304 | } | 304 | } |
305 | /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ | 305 | /* after the loop, a[i] >= P and a[lo .. i - 1] < P (a) */ |
306 | /* next loop: repeat --j while P < a[j] */ | 306 | /* next loop: repeat --j while P < a[j] */ |
307 | while ((void)geti(L, 1, --j), sort_comp(L, -3, -1)) { | 307 | while ((void)geti(L, 1, --j), sort_comp(L, -3, -1)) { |
308 | if (l_unlikely(j < i)) /* j < i but a[j] > P ?? */ | 308 | if (l_unlikely(j < i)) /* j <= i - 1 and a[j] > P, contradicts (a) */ |
309 | luaL_error(L, "invalid order function for sorting"); | 309 | luaL_error(L, "invalid order function for sorting"); |
310 | lua_pop(L, 1); /* remove a[j] */ | 310 | lua_pop(L, 1); /* remove a[j] */ |
311 | } | 311 | } |