mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx: add simple SORT_CMP_SWAP()
macro for MDBX_HAVE_CMOV=0
case.
This commit is contained in:
parent
480dc2531e
commit
d28110373e
11
src/core.c
11
src/core.c
@ -1872,6 +1872,7 @@ static int lcklist_detach_locked(MDBX_env *env) {
|
||||
* and network-sort for small chunks.
|
||||
* Thanks to John M. Gamble for the http://pages.ripco.net/~jgamble/nw.html */
|
||||
|
||||
#if MDBX_HAVE_CMOV
|
||||
#define SORT_CMP_SWAP(TYPE, CMP, a, b) \
|
||||
do { \
|
||||
const TYPE swap_tmp = (a); \
|
||||
@ -1879,6 +1880,16 @@ static int lcklist_detach_locked(MDBX_env *env) {
|
||||
(a) = swap_cmp ? swap_tmp : b; \
|
||||
(b) = swap_cmp ? b : swap_tmp; \
|
||||
} while (0)
|
||||
#else
|
||||
#define SORT_CMP_SWAP(TYPE, CMP, a, b) \
|
||||
do \
|
||||
if (!CMP(a, b)) { \
|
||||
const TYPE swap_tmp = (a); \
|
||||
(a) = (b); \
|
||||
(b) = swap_tmp; \
|
||||
} \
|
||||
while (0)
|
||||
#endif
|
||||
|
||||
// 3 comparators, 3 parallel operations
|
||||
// o-----^--^--o
|
||||
|
Loading…
Reference in New Issue
Block a user