mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx: refine mdbx_cmp2int().
Change-Id: I5497db2e88d764e18a1aae1809dc66fd62a5adbe
This commit is contained in:
parent
026a566fc6
commit
90aa4b154a
6
mdb.c
6
mdb.c
@ -5136,7 +5136,11 @@ mdb_env_close(MDB_env *env)
|
|||||||
* | 1, a > b
|
* | 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. */
|
/** Compare two items pointing at aligned unsigned int's. */
|
||||||
static int __hot
|
static int __hot
|
||||||
|
5
midl.c
5
midl.c
@ -28,7 +28,6 @@
|
|||||||
/** @defgroup idls ID List Management
|
/** @defgroup idls ID List Management
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define CMP(x,y) ( (x) < (y) ? -1 : (x) > (y) )
|
|
||||||
|
|
||||||
static unsigned __hot
|
static unsigned __hot
|
||||||
mdb_midl_search( MDB_IDL ids, MDB_ID id )
|
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 ) {
|
while( 0 < n ) {
|
||||||
unsigned pivot = n >> 1;
|
unsigned pivot = n >> 1;
|
||||||
cursor = base + pivot + 1;
|
cursor = base + pivot + 1;
|
||||||
val = CMP( ids[cursor], id );
|
val = mdbx_cmp2int( ids[cursor], id );
|
||||||
|
|
||||||
if( val < 0 ) {
|
if( val < 0 ) {
|
||||||
n = pivot;
|
n = pivot;
|
||||||
@ -295,7 +294,7 @@ mdb_mid2l_search( MDB_ID2L ids, MDB_ID id )
|
|||||||
while( 0 < n ) {
|
while( 0 < n ) {
|
||||||
unsigned pivot = n >> 1;
|
unsigned pivot = n >> 1;
|
||||||
cursor = base + pivot + 1;
|
cursor = base + pivot + 1;
|
||||||
val = CMP( id, ids[cursor].mid );
|
val = mdbx_cmp2int( id, ids[cursor].mid );
|
||||||
|
|
||||||
if( val < 0 ) {
|
if( val < 0 ) {
|
||||||
n = pivot;
|
n = pivot;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user