mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-08 04:44:14 +08:00
mdbx: fix pnl_sort().
Change-Id: I57f9a8dd8d61c6f11f8f30d15f8812cf2f850789
This commit is contained in:
parent
ffa8f55354
commit
128cc2d308
10
src/mdbx.c
10
src/mdbx.c
@ -235,7 +235,7 @@ static void __hot mdbx_pnl_sort(MDBX_PNL pnl) {
|
|||||||
for (j = l + 1; j <= ir; j++) {
|
for (j = l + 1; j <= ir; j++) {
|
||||||
a = pnl[j];
|
a = pnl[j];
|
||||||
for (i = j - 1; i >= 1; i--) {
|
for (i = j - 1; i >= 1; i--) {
|
||||||
if (MDBX_PNL_ORDERED(pnl[i], a))
|
if (MDBX_PNL_DISORDERED(a, pnl[i]))
|
||||||
break;
|
break;
|
||||||
pnl[i + 1] = pnl[i];
|
pnl[i + 1] = pnl[i];
|
||||||
}
|
}
|
||||||
@ -248,13 +248,13 @@ static void __hot mdbx_pnl_sort(MDBX_PNL pnl) {
|
|||||||
} else {
|
} else {
|
||||||
k = (l + ir) >> 1; /* Choose median of left, center, right */
|
k = (l + ir) >> 1; /* Choose median of left, center, right */
|
||||||
PNL_SWAP(pnl[k], pnl[l + 1]);
|
PNL_SWAP(pnl[k], pnl[l + 1]);
|
||||||
if (MDBX_PNL_DISORDERED(pnl[l], pnl[ir]))
|
if (MDBX_PNL_ORDERED(pnl[ir], pnl[l]))
|
||||||
PNL_SWAP(pnl[l], pnl[ir]);
|
PNL_SWAP(pnl[l], pnl[ir]);
|
||||||
|
|
||||||
if (MDBX_PNL_DISORDERED(pnl[l + 1], pnl[ir]))
|
if (MDBX_PNL_ORDERED(pnl[ir], pnl[l + 1]))
|
||||||
PNL_SWAP(pnl[l + 1], pnl[ir]);
|
PNL_SWAP(pnl[l + 1], pnl[ir]);
|
||||||
|
|
||||||
if (MDBX_PNL_DISORDERED(pnl[l], pnl[l + 1]))
|
if (MDBX_PNL_ORDERED(pnl[l + 1], pnl[l]))
|
||||||
PNL_SWAP(pnl[l], pnl[l + 1]);
|
PNL_SWAP(pnl[l], pnl[l + 1]);
|
||||||
|
|
||||||
i = l + 1;
|
i = l + 1;
|
||||||
@ -266,7 +266,7 @@ static void __hot mdbx_pnl_sort(MDBX_PNL pnl) {
|
|||||||
while (MDBX_PNL_ORDERED(pnl[i], a));
|
while (MDBX_PNL_ORDERED(pnl[i], a));
|
||||||
do
|
do
|
||||||
j--;
|
j--;
|
||||||
while (MDBX_PNL_DISORDERED(pnl[j], a));
|
while (MDBX_PNL_ORDERED(a, pnl[j]));
|
||||||
if (j < i)
|
if (j < i)
|
||||||
break;
|
break;
|
||||||
PNL_SWAP(pnl[i], pnl[j]);
|
PNL_SWAP(pnl[i], pnl[j]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user