diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-09-12 11:08:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-09-12 11:08:11 -0300 |
commit | b443145ff3415fcaee903a7d95fa7212df5a77db (patch) | |
tree | b1875635a568d42741103b05f026c58147e70090 /ltablib.c | |
parent | 4901853c1163d0bba81ef1579835cb2b6560e245 (diff) | |
download | lua-b443145ff3415fcaee903a7d95fa7212df5a77db.tar.gz lua-b443145ff3415fcaee903a7d95fa7212df5a77db.tar.bz2 lua-b443145ff3415fcaee903a7d95fa7212df5a77db.zip |
Details
Fixed comments in sort partition.
Diffstat (limited to 'ltablib.c')
-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 | } |