mdbx: refine mdbx_cmp2int().

Change-Id: I5497db2e88d764e18a1aae1809dc66fd62a5adbe
This commit is contained in:
Leo Yuriev 2016-04-19 00:44:30 +03:00
parent 026a566fc6
commit 90aa4b154a
2 changed files with 7 additions and 4 deletions

6
mdb.c
View File

@ -5136,7 +5136,11 @@ mdb_env_close(MDB_env *env)
* | 1, a > b
* \
*/
#define mdbx_cmp2int(a, b) (((a) > (b)) - ((b) > (a)))
#if 1
# define mdbx_cmp2int(a, b) (((b) > (a)) ? -1 : (a) > (b))
#else
# define mdbx_cmp2int(a, b) (((a) > (b)) - ((b) > (a)))
#endif
/** Compare two items pointing at aligned unsigned int's. */
static int __hot

5
midl.c
View File

@ -28,7 +28,6 @@
/** @defgroup idls ID List Management
* @{
*/
#define CMP(x,y) ( (x) < (y) ? -1 : (x) > (y) )
static unsigned __hot
mdb_midl_search( MDB_IDL ids, MDB_ID id )
@ -46,7 +45,7 @@ mdb_midl_search( MDB_IDL ids, MDB_ID id )
while( 0 < n ) {
unsigned pivot = n >> 1;
cursor = base + pivot + 1;
val = CMP( ids[cursor], id );
val = mdbx_cmp2int( ids[cursor], id );
if( val < 0 ) {
n = pivot;
@ -295,7 +294,7 @@ mdb_mid2l_search( MDB_ID2L ids, MDB_ID id )
while( 0 < n ) {
unsigned pivot = n >> 1;
cursor = base + pivot + 1;
val = CMP( id, ids[cursor].mid );
val = mdbx_cmp2int( id, ids[cursor].mid );
if( val < 0 ) {
n = pivot;