Skip to content

Commit b443145

Browse files
committed
Details
Fixed comments in sort partition.
1 parent 4901853 commit b443145

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ltablib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) {
298298
for (;;) {
299299
/* next loop: repeat ++i while a[i] < P */
300300
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] */
302302
luaL_error(L, "invalid order function for sorting");
303303
lua_pop(L, 1); /* remove a[i] */
304304
}
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) */
306306
/* next loop: repeat --j while P < a[j] */
307307
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) */
309309
luaL_error(L, "invalid order function for sorting");
310310
lua_pop(L, 1); /* remove a[j] */
311311
}

0 commit comments

Comments
 (0)