From e2ec25e51125210ea1f7c56119b08e14f04ac5af Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 1 Jul 2024 15:08:23 -0500 Subject: [PATCH] Tweaked btree/bshrub rbyd commit_ to accept any bid This gets a bit muddled now with traversals mutating inner btree nodes directly. Except for some asserts, we can accept any bid in the relevant rbyd here, and accepting any bid is better than accepting only one bid (left-leaning) inconsistent with the rest of the btree API (right-leaning)... Code changes minimal: code stack before: 35448 2800 after: 35440 (-0.0%) 2800 (+0.0%) --- lfs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lfs.c b/lfs.c index 3a81494d..321a354d 100644 --- a/lfs.c +++ b/lfs.c @@ -4786,7 +4786,6 @@ static int lfsr_btree_commit__(lfs_t *lfs, lfsr_btree_t *btree, recurse:; // done? if (!lfsr_rbyd_trunk(&parent)) { - LFS_ASSERT(bid == 0); *btree = rbyd_; *attr_count_ = 0; return 0; @@ -4894,9 +4893,8 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree, return err; } - // adjust bid to point to the zero-most rid - bid -= rid_; - rid -= bid; + // adjust rid + rid -= (bid-rid_); } return lfsr_btree_commit_(lfs, btree, bid, &rbyd, rid, @@ -5814,10 +5812,8 @@ static int lfsr_bshrub_commit(lfs_t *lfs, return err; } - // TODO - // adjust bid to point to the zero-most rid - bid -= rid_; - rid -= bid; + // adjust rid + rid -= (bid-rid_); } return lfsr_bshrub_commit_(lfs, mdir, bshrub, bid, &rbyd, rid,