mdbx: minor refine mdbx_rebalance().

Change-Id: I10a6a208b173bdee1d325aa7b2624de879814647
This commit is contained in:
Leonid Yuriev 2020-11-03 03:01:02 +03:00
parent b209e91ad4
commit 37a1d546b7

View File

@ -14926,8 +14926,7 @@ static int mdbx_rebalance(MDBX_cursor *mc) {
mc->mc_db->md_overflow_pages == 0 && mc->mc_db->md_overflow_pages == 0 &&
mc->mc_db->md_leaf_pages == 1); mc->mc_db->md_leaf_pages == 1);
/* Adjust cursors pointing to mp */ /* Adjust cursors pointing to mp */
const MDBX_dbi dbi = mc->mc_dbi; for (MDBX_cursor *m2 = mc->mc_txn->mt_cursors[mc->mc_dbi]; m2;
for (MDBX_cursor *m2 = mc->mc_txn->mt_cursors[dbi]; m2;
m2 = m2->mc_next) { m2 = m2->mc_next) {
MDBX_cursor *m3 = MDBX_cursor *m3 =
(mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2; (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
@ -14961,10 +14960,10 @@ static int mdbx_rebalance(MDBX_cursor *mc) {
} }
/* Adjust other cursors pointing to mp */ /* Adjust other cursors pointing to mp */
MDBX_cursor *m2, *m3; for (MDBX_cursor *m2 = mc->mc_txn->mt_cursors[mc->mc_dbi]; m2;
MDBX_dbi dbi = mc->mc_dbi; m2 = m2->mc_next) {
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) { MDBX_cursor *m3 =
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2; (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
if (m3 == mc || !(m3->mc_flags & C_INITIALIZED)) if (m3 == mc || !(m3->mc_flags & C_INITIALIZED))
continue; continue;
if (m3->mc_pg[0] == mp) { if (m3->mc_pg[0] == mp) {
@ -15116,7 +15115,8 @@ static int mdbx_rebalance(MDBX_cursor *mc) {
mdbx_cassert(mc, rc || page_numkeys(mc->mc_pg[mc->mc_top]) >= minkeys); mdbx_cassert(mc, rc || page_numkeys(mc->mc_pg[mc->mc_top]) >= minkeys);
return rc; return rc;
} }
} else if (likely(right)) { }
if (likely(right)) {
/* try merge with right */ /* try merge with right */
mdbx_cassert(mc, page_numkeys(right) >= minkeys); mdbx_cassert(mc, page_numkeys(right) >= minkeys);
mn.mc_pg[mn.mc_top] = right; mn.mc_pg[mn.mc_top] = right;