mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 18:58:22 +08:00
mdbx: more cleanup mdbx_midl_sort().
This commit is contained in:
parent
eff0f92fa7
commit
2f97939efd
20
src/mdbx.c
20
src/mdbx.c
@ -9411,11 +9411,11 @@ static void __hot mdbx_midl_xmerge(MDB_IDL idl, MDB_IDL merge) {
|
|||||||
/* Quicksort + Insertion sort for small arrays */
|
/* Quicksort + Insertion sort for small arrays */
|
||||||
#define SMALL 8
|
#define SMALL 8
|
||||||
#define MIDL_SWAP(a, b) \
|
#define MIDL_SWAP(a, b) \
|
||||||
{ \
|
do { \
|
||||||
pgno_t itmp = (a); \
|
pgno_t tmp_pgno = (a); \
|
||||||
(a) = (b); \
|
(a) = (b); \
|
||||||
(b) = itmp; \
|
(b) = tmp_pgno; \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
static void __hot mdbx_midl_sort(MDB_IDL ids) {
|
static void __hot mdbx_midl_sort(MDB_IDL ids) {
|
||||||
/* Max possible depth of int-indexed tree * 2 items/level */
|
/* Max possible depth of int-indexed tree * 2 items/level */
|
||||||
@ -9444,15 +9444,15 @@ static void __hot mdbx_midl_sort(MDB_IDL ids) {
|
|||||||
} else {
|
} else {
|
||||||
k = (l + ir) >> 1; /* Choose median of left, center, right */
|
k = (l + ir) >> 1; /* Choose median of left, center, right */
|
||||||
MIDL_SWAP(ids[k], ids[l + 1]);
|
MIDL_SWAP(ids[k], ids[l + 1]);
|
||||||
if (ids[l] < ids[ir]) {
|
if (ids[l] < ids[ir])
|
||||||
MIDL_SWAP(ids[l], ids[ir]);
|
MIDL_SWAP(ids[l], ids[ir]);
|
||||||
}
|
|
||||||
if (ids[l + 1] < ids[ir]) {
|
if (ids[l + 1] < ids[ir])
|
||||||
MIDL_SWAP(ids[l + 1], ids[ir]);
|
MIDL_SWAP(ids[l + 1], ids[ir]);
|
||||||
}
|
|
||||||
if (ids[l] < ids[l + 1]) {
|
if (ids[l] < ids[l + 1])
|
||||||
MIDL_SWAP(ids[l], ids[l + 1]);
|
MIDL_SWAP(ids[l], ids[l + 1]);
|
||||||
}
|
|
||||||
i = l + 1;
|
i = l + 1;
|
||||||
j = ir;
|
j = ir;
|
||||||
a = ids[l + 1];
|
a = ids[l + 1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user