Adopted more single-char field names

Limited to nested struct fields where the names don't really matter:

- bptr.data -> bptr.d
- mdir.rbyd -> mdir.r

Ok it actually just ended up those two.

This is on the tail end of some optimization work that ended up
abandoned because of maintainability concerns. But it did highlight that
struct nesting gets a bit out-of-control when trying to both optimize
stack allocations and respect C99's strict aliasing.

Consider further fragmenting lfs3_rbyd_t for fine-grain stack
allocations:

  typedef struct lfs3_rbyd {
      struct lfs3_rtrunkcksum {
          struct lfs3_rtrunk {
              lfs3_rid_t weight;
              struct lfs3_rtrunktrunk {
                  lfs3_block_t blocks[2];
                  lfs3_size_t trunk;
              } rtrunktrunk;
          } rtrunk;
          uint32_t cksum;
      } rtrunkcksum;
      lfs3_size_t eoff;
  } lfs3_rbyd_t;

Accessing fields just starts to get silly:

  rbyd.rtrunkcksum.rtrunk.trunktrunk.trunk

At least single-char field names keeps a little bit of readability:

  rbyd.ck.t.t.trunk

Or for some real examples:

- file->b.o.mdir.rbyd.weight -> file->b.o.mdir.r.weight
- bptr->data.u.disk.block -> bptr->d.u.disk.block
This commit is contained in:
Christopher Haster
2025-07-14 15:12:51 -05:00
parent 29e1701964
commit 0bed3867d8
9 changed files with 788 additions and 788 deletions
+30 -30
View File
@@ -226,9 +226,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -375,9 +375,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
@@ -640,9 +640,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -804,9 +804,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
@@ -2131,9 +2131,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// all blocks should have been fragmented
assert(false);
@@ -2283,9 +2283,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// all blocks should have been fragmented
assert(false);
@@ -2582,9 +2582,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -2750,9 +2750,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
@@ -3042,9 +3042,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -3214,9 +3214,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;