From dce5bb2fee751d623327005e0c2ba625fae66c1f Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Thu, 12 Apr 2012 07:34:14 +0200 Subject: [PATCH] libmdb: Simplify mdb_default_cmp. No real change. --- libraries/libmdb/mdb.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 4f703e40fc..344144aadd 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -6117,27 +6117,17 @@ mdb_env_stat(MDB_env *env, MDB_stat *arg) static void mdb_default_cmp(MDB_txn *txn, MDB_dbi dbi) { - if (txn->mt_dbs[dbi].md_flags & MDB_REVERSEKEY) - txn->mt_dbxs[dbi].md_cmp = mdb_cmp_memnr; - else if (txn->mt_dbs[dbi].md_flags & MDB_INTEGERKEY) - txn->mt_dbxs[dbi].md_cmp = mdb_cmp_cint; - else - txn->mt_dbxs[dbi].md_cmp = mdb_cmp_memn; + uint16_t f = txn->mt_dbs[dbi].md_flags; - if (txn->mt_dbs[dbi].md_flags & MDB_DUPSORT) { - if (txn->mt_dbs[dbi].md_flags & MDB_INTEGERDUP) { - if (txn->mt_dbs[dbi].md_flags & MDB_DUPFIXED) - txn->mt_dbxs[dbi].md_dcmp = mdb_cmp_int; - else - txn->mt_dbxs[dbi].md_dcmp = mdb_cmp_cint; - } else if (txn->mt_dbs[dbi].md_flags & MDB_REVERSEDUP) { - txn->mt_dbxs[dbi].md_dcmp = mdb_cmp_memnr; - } else { - txn->mt_dbxs[dbi].md_dcmp = mdb_cmp_memn; - } - } else { - txn->mt_dbxs[dbi].md_dcmp = NULL; - } + txn->mt_dbxs[dbi].md_cmp = + (f & MDB_REVERSEKEY) ? mdb_cmp_memnr : + (f & MDB_INTEGERKEY) ? mdb_cmp_cint : mdb_cmp_memn; + + txn->mt_dbxs[dbi].md_dcmp = + !(f & MDB_DUPSORT) ? 0 : + ((f & MDB_INTEGERDUP) + ? ((f & MDB_DUPFIXED) ? mdb_cmp_int : mdb_cmp_cint) + : ((f & MDB_REVERSEDUP) ? mdb_cmp_memnr : mdb_cmp_memn)); } int mdb_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi) -- 2.39.5