Typedefed lfsr_shrub_t -> lfsr_rbyd_t, replacing lfsr_bshrub_t union

The lfsr_shrub_t/lfsr_btree_t union was _technically_ not undefined
behavior, because the relevant fields were all a part of the "common
initial sequence", but collapsing these to the same type certainly does
simplify things.

The only weirdness is that we now store shrub.estimate in shrub.eoff.

We could add a union here, but the extra noise is just not worth the
slighty better name. The shrub.estimate is a sort of "simulated
shrub.eoff" anyways.

---

This makes it so all of these types alias to the same core lfsr_rbyd_t
type, which I suppose actually reflects the on-disk format quite well:

  lfsr_shrub_t  => lfsr_rbyd_t
  lfsr_bshrub_t
  lfsr_btree_t

Code cost more-or-less unaffected:

           code          stack          ctx
  before: 36432           2608          640
  after:  36436 (+0.0%)   2608 (+0.0%)  640 (+0.0%)
This commit is contained in:
Christopher Haster
2025-02-03 02:17:52 -06:00
parent 192c58318f
commit 7c17be4dbe
3 changed files with 91 additions and 107 deletions
+6 -18
View File
@@ -605,14 +605,7 @@ typedef struct lfsr_rbyd {
typedef lfsr_rbyd_t lfsr_btree_t;
// a shrub is a secondary trunk in an mdir
typedef struct {
// this mostly lines up with lfsr_rbyd_t
lfsr_rid_t weight;
lfs_block_t blocks[2];
lfs_size_t trunk;
// except for shrub estimate, which takes the place of eoff, etc
lfs_size_t estimate;
} lfsr_shrub_t;
typedef lfsr_rbyd_t lfsr_shrub_t;
typedef struct lfsr_mdir {
lfsr_smid_t mid;
@@ -694,16 +687,11 @@ typedef struct lfsr_bptr {
} lfsr_bptr_t;
// the lfsr_bshrub_t struct represents the on-disk component of a file
typedef struct lfsr_bshrub {
// weight=0 => no bshrub/btree
// sign(weight)=1 => bshrub
// sign(weight)=0 => btree
union {
lfs_size_t weight;
lfsr_shrub_t bshrub;
lfsr_btree_t btree;
} u;
} lfsr_bshrub_t;
//
// weight=0 => no bshrub/btree
// sign(weight)=1 => bshrub
// sign(weight)=0 => btree
typedef lfsr_rbyd_t lfsr_bshrub_t;
typedef struct lfsr_obshrub {
// bshrubs need to be tracked for commits to work