mdbx: avoid branches inside bsearch() loop.

Related for https://github.com/erthink/libmdbx/issues/132

Change-Id: Ia843556cc7052e5081a98f56b43fd80e2d0a40c7
This commit is contained in:
Leonid Yuriev 2021-02-01 00:39:52 +03:00
parent 28bd5d81d2
commit 88bdf4b96f

View File

@ -2698,10 +2698,10 @@ static int lcklist_detach_locked(MDBX_env *env) {
const unsigned whole = length; \ const unsigned whole = length; \
length >>= 1; \ length >>= 1; \
const TYPE_LIST *const middle = first + length; \ const TYPE_LIST *const middle = first + length; \
if (CMP(*middle, item)) { \ const unsigned left = whole - length - 1; \
first = middle + 1; \ const bool cmp = CMP(*middle, item); \
length = whole - length - 1; \ length = cmp ? left : length; \
} \ first = cmp ? middle + 1 : first; \
} \ } \
\ \
switch (length) { \ switch (length) { \