mdbx: 'unlikely' for DB_STALE.

This commit is contained in:
Leo Yuriev 2017-02-15 20:04:20 +03:00
parent acdaeeab5c
commit cf8ef06ebc

9
mdb.c
View File

@ -5763,7 +5763,7 @@ mdb_page_search(MDB_cursor *mc, MDB_val *key, int flags)
return MDB_BAD_TXN; return MDB_BAD_TXN;
} else { } else {
/* Make sure we're using an up-to-date root */ /* Make sure we're using an up-to-date root */
if (*mc->mc_dbflag & DB_STALE) { if (unlikely(*mc->mc_dbflag & DB_STALE)) {
MDB_cursor mc2; MDB_cursor mc2;
if (unlikely(TXN_DBI_CHANGED(mc->mc_txn, mc->mc_dbi))) if (unlikely(TXN_DBI_CHANGED(mc->mc_txn, mc->mc_dbi)))
return MDB_BAD_DBI; return MDB_BAD_DBI;
@ -7826,15 +7826,14 @@ mdb_cursor_init(MDB_cursor *mc, MDB_txn *txn, MDB_dbi dbi, MDB_xcursor *mx)
mc->mc_pg[0] = 0; mc->mc_pg[0] = 0;
mc->mc_flags = 0; mc->mc_flags = 0;
mc->mc_ki[0] = 0; mc->mc_ki[0] = 0;
mc->mc_xcursor = NULL;
if (txn->mt_dbs[dbi].md_flags & MDB_DUPSORT) { if (txn->mt_dbs[dbi].md_flags & MDB_DUPSORT) {
mdb_tassert(txn, mx != NULL); mdb_tassert(txn, mx != NULL);
mx->mx_cursor.mc_signature = MDBX_MC_SIGNATURE; mx->mx_cursor.mc_signature = MDBX_MC_SIGNATURE;
mc->mc_xcursor = mx; mc->mc_xcursor = mx;
mdb_xcursor_init0(mc); mdb_xcursor_init0(mc);
} else {
mc->mc_xcursor = NULL;
} }
if (*mc->mc_dbflag & DB_STALE) { if (unlikely(*mc->mc_dbflag & DB_STALE)) {
mdb_page_search(mc, NULL, MDB_PS_ROOTONLY); mdb_page_search(mc, NULL, MDB_PS_ROOTONLY);
} }
} }
@ -10226,7 +10225,7 @@ mdbx_stat(MDB_txn *txn, MDB_dbi dbi, MDBX_stat *arg, size_t bytes)
if (unlikely(txn->mt_flags & MDB_TXN_BLOCKED)) if (unlikely(txn->mt_flags & MDB_TXN_BLOCKED))
return MDB_BAD_TXN; return MDB_BAD_TXN;
if (txn->mt_dbflags[dbi] & DB_STALE) { if (unlikely(txn->mt_dbflags[dbi] & DB_STALE)) {
MDB_cursor mc; MDB_cursor mc;
MDB_xcursor mx; MDB_xcursor mx;
/* Stale, must read the DB's root. cursor_init does it for us. */ /* Stale, must read the DB's root. cursor_init does it for us. */