From d3e609d7ff2de35d23a90f42a57634b0a6c459d3 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 16 May 2020 13:02:57 +0300 Subject: [PATCH] mdbx: simplify page-merge for LEAF2. Change-Id: I25ad34f02b86b47562fc3c74f5454432f687cbde --- src/core.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/core.c b/src/core.c index b6176d6d..44628323 100644 --- a/src/core.c +++ b/src/core.c @@ -13823,21 +13823,17 @@ static int mdbx_page_merge(MDBX_cursor *csrc, MDBX_cursor *cdst) { if (unlikely(rc)) return rc; - const MDBX_node *lowest; const MDBX_page *mp = mn.mc_pg[mn.mc_top]; - if (unlikely(IS_LEAF2(mp))) { - mdbx_cassert(&mn, mn.mc_top > csrc->mc_top); - unsigned i = mn.mc_top; - do - mp = mn.mc_pg[--i]; - while (i && IS_BRANCH(mp) && mn.mc_ki[i] == 0); - lowest = page_node(mp, mn.mc_ki[i]); - } else { + if (likely(!IS_LEAF2(mp))) { mdbx_cassert(&mn, IS_LEAF(mp)); - lowest = page_node(mp, 0); + const MDBX_node *lowest = page_node(mp, 0); + key.iov_len = node_ks(lowest); + key.iov_base = node_key(lowest); + } else { + mdbx_cassert(&mn, mn.mc_top > csrc->mc_top); + key.iov_len = mp->mp_leaf2_ksize; + key.iov_base = page_leaf2key(mp, mn.mc_ki[mn.mc_top], key.iov_len); } - key.iov_len = node_ks(lowest); - key.iov_base = node_key(lowest); mdbx_cassert(&mn, key.iov_len >= csrc->mc_dbx->md_klen_min); mdbx_cassert(&mn, key.iov_len <= csrc->mc_dbx->md_klen_max);