commit b443145ff3415fcaee903a7d95fa7212df5a77db
parent 4901853c1163d0bba81ef1579835cb2b6560e245
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 12 Sep 2024 11:07:44 -0300
Details
Fixed comments in sort partition.
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ltablib.c b/ltablib.c
@@ -298,14 +298,14 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) {
for (;;) {
/* next loop: repeat ++i while a[i] < P */
while ((void)geti(L, 1, ++i), sort_comp(L, -1, -2)) {
- if (l_unlikely(i == up - 1)) /* a[i] < P but a[up - 1] == P ?? */
+ if (l_unlikely(i == up - 1)) /* a[up - 1] < P == a[up - 1] */
luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[i] */
}
- /* after the loop, a[i] >= P and a[lo .. i - 1] < P */
+ /* after the loop, a[i] >= P and a[lo .. i - 1] < P (a) */
/* next loop: repeat --j while P < a[j] */
while ((void)geti(L, 1, --j), sort_comp(L, -3, -1)) {
- if (l_unlikely(j < i)) /* j < i but a[j] > P ?? */
+ if (l_unlikely(j < i)) /* j <= i - 1 and a[j] > P, contradicts (a) */
luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[j] */
}