From: Howard Chu Date: Mon, 23 Jul 2012 00:42:36 +0000 (-0700) Subject: Leave extra space when creating a fake page X-Git-Tag: OPENLDAP_REL_ENG_2_4_32~57^2~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ccc4d23e749edc5ea461261427a0ee0a663fdfe5;p=openldap Leave extra space when creating a fake page Minimizes the number of memcpy's if additional dups are stored. --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 21fa97792c..be009ced55 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -4321,6 +4321,7 @@ more: if (mc->mc_db->md_flags & MDB_DUPFIXED) { fp->mp_flags |= P_LEAF2; fp->mp_pad = data->mv_size; + fp->mp_upper += 2 * data->mv_size; /* leave space for 2 more */ } else { fp->mp_upper += 2 * sizeof(indx_t) + 2 * NODESIZE + (dkey.mv_size & 1) + (data->mv_size & 1); @@ -4341,6 +4342,7 @@ more: fp = NODEDATA(leaf); if (flags == MDB_CURRENT) { +reuse: fp->mp_flags |= P_DIRTY; COPY_PGNO(fp->mp_pgno, mc->mc_pg[mc->mc_top]->mp_pgno); mc->mc_xcursor->mx_cursor.mc_pg[0] = fp; @@ -4349,6 +4351,9 @@ more: } if (mc->mc_db->md_flags & MDB_DUPFIXED) { offset = fp->mp_pad; + if (SIZELEFT(fp) >= offset) + goto reuse; + offset *= 4; /* space for 4 more */ } else { offset = NODESIZE + sizeof(indx_t) + data->mv_size; }