mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-05 09:12:07 +08:00
mdbx: backport - Refactor mdb_page_get().
Change-Id: I6a44000d954025f87637c8b60da85b210b4df65e
This commit is contained in:
parent
259e21c85f
commit
f627930bdc
15
mdb.c
15
mdb.c
@ -5399,10 +5399,8 @@ mdb_page_get(MDB_txn *txn, pgno_t pgno, MDB_page **ret, int *lvl)
|
|||||||
if (tx2->mt_spill_pgs) {
|
if (tx2->mt_spill_pgs) {
|
||||||
MDB_ID pn = pgno << 1;
|
MDB_ID pn = pgno << 1;
|
||||||
x = mdb_midl_search(tx2->mt_spill_pgs, pn);
|
x = mdb_midl_search(tx2->mt_spill_pgs, pn);
|
||||||
if (x <= tx2->mt_spill_pgs[0] && tx2->mt_spill_pgs[x] == pn) {
|
if (x <= tx2->mt_spill_pgs[0] && tx2->mt_spill_pgs[x] == pn)
|
||||||
p = (MDB_page *)(env->me_map + env->me_psize * pgno);
|
goto mapped;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (dl[0].mid) {
|
if (dl[0].mid) {
|
||||||
unsigned x = mdb_mid2l_search(dl, pgno);
|
unsigned x = mdb_mid2l_search(dl, pgno);
|
||||||
@ -5415,14 +5413,15 @@ mdb_page_get(MDB_txn *txn, pgno_t pgno, MDB_page **ret, int *lvl)
|
|||||||
} while ((tx2 = tx2->mt_parent) != NULL);
|
} while ((tx2 = tx2->mt_parent) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likely(pgno < txn->mt_next_pgno)) {
|
if (unlikely(pgno >= txn->mt_next_pgno)) {
|
||||||
level = 0;
|
|
||||||
p = (MDB_page *)(env->me_map + env->me_psize * pgno);
|
|
||||||
} else {
|
|
||||||
mdb_debug("page %zu not found", pgno);
|
mdb_debug("page %zu not found", pgno);
|
||||||
txn->mt_flags |= MDB_TXN_ERROR;
|
txn->mt_flags |= MDB_TXN_ERROR;
|
||||||
return MDB_PAGE_NOTFOUND;
|
return MDB_PAGE_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
level = 0;
|
||||||
|
|
||||||
|
mapped:
|
||||||
|
p = (MDB_page *)(env->me_map + env->me_psize * pgno);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
*ret = p;
|
*ret = p;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user