mirror of
https://github.com/lua/lua.git
synced 2024-11-23 02:03:55 +08:00
Details
Fixed comments in sort partition.
This commit is contained in:
parent
4901853c11
commit
b443145ff3
@ -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] */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user