mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:14:12 +08:00
lmdb: Use mdb_cmp_int_a/mdb_cmp_long() for FREE_DBI.
Change-Id: Id66356b27e9d257fbf5bc8ce1111845be8683d62
This commit is contained in:
parent
84b6ecb9a8
commit
b13d850bd7
9
mdb.c
9
mdb.c
@ -4637,6 +4637,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned flags, mode_t mode)
|
|||||||
rc = ENOMEM;
|
rc = ENOMEM;
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
env->me_dbxs[FREE_DBI].md_cmp = mdb_cmp_int_a; /* aligned MDB_INTEGERKEY */
|
||||||
|
|
||||||
/* For RDONLY, get lockfile after we know datafile exists */
|
/* For RDONLY, get lockfile after we know datafile exists */
|
||||||
if (!(flags & MDB_RDONLY)) {
|
if (!(flags & MDB_RDONLY)) {
|
||||||
@ -4814,7 +4815,7 @@ mdb_cmp_int_a(const MDB_val *a, const MDB_val *b)
|
|||||||
mdb_assert(NULL, a->mv_size == b->mv_size);
|
mdb_assert(NULL, a->mv_size == b->mv_size);
|
||||||
mdb_assert(NULL, 0 == (uintptr_t) a->mv_data % sizeof(int));
|
mdb_assert(NULL, 0 == (uintptr_t) a->mv_data % sizeof(int));
|
||||||
|
|
||||||
if (sizeof(int) != sizeof(size_t) && a->mv_size == sizeof(size_t))
|
if (sizeof(int) != sizeof(size_t) && likely(a->mv_size == sizeof(size_t)))
|
||||||
return (*(size_t *)a->mv_data < *(size_t *)b->mv_data) ? -1 :
|
return (*(size_t *)a->mv_data < *(size_t *)b->mv_data) ? -1 :
|
||||||
*(size_t *)a->mv_data > *(size_t *)b->mv_data;
|
*(size_t *)a->mv_data > *(size_t *)b->mv_data;
|
||||||
|
|
||||||
@ -4833,7 +4834,7 @@ mdb_cmp_int_na(const MDB_val *a, const MDB_val *b)
|
|||||||
mdb_assert(NULL, 0 == (uintptr_t) a->mv_data % sizeof(short)
|
mdb_assert(NULL, 0 == (uintptr_t) a->mv_data % sizeof(short)
|
||||||
&& 0 == (uintptr_t) b->mv_data % sizeof(short));
|
&& 0 == (uintptr_t) b->mv_data % sizeof(short));
|
||||||
#ifdef MISALIGNED_OK
|
#ifdef MISALIGNED_OK
|
||||||
if (sizeof(int) != sizeof(size_t) && a->mv_size == sizeof(size_t)) {
|
if (sizeof(int) != sizeof(size_t) && likely(a->mv_size == sizeof(size_t))) {
|
||||||
return (*(size_t *)a->mv_data < *(size_t *)b->mv_data) ? -1 :
|
return (*(size_t *)a->mv_data < *(size_t *)b->mv_data) ? -1 :
|
||||||
*(size_t *)a->mv_data > *(size_t *)b->mv_data;
|
*(size_t *)a->mv_data > *(size_t *)b->mv_data;
|
||||||
}
|
}
|
||||||
@ -9124,10 +9125,6 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned flags, MDB_dbi *dbi)
|
|||||||
unsigned unused = 0, seq;
|
unsigned unused = 0, seq;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (txn->mt_dbxs[FREE_DBI].md_cmp == NULL) {
|
|
||||||
mdb_default_cmp(txn, FREE_DBI);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & VALID_FLAGS) != flags)
|
if ((flags & VALID_FLAGS) != flags)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (txn->mt_flags & MDB_TXN_ERROR)
|
if (txn->mt_flags & MDB_TXN_ERROR)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user