Collapsed lfsr_ftree_t struct into lfsr_file_t

One less struct to worry about, and less code/stack pressure from
passing around multiple pointers.

There were some naming collisions:

- lfsr_ftree_size -> lfsr_file_bsize
- lfsr_ftree_read -> lfsr_file_read_
- lfsr_ftree_flush -> lfsr_file_flush_

I'm not sure this should be the final result. There are definitely some
rough spots, the hacky "pseudo-file" in lfsr_traversal_t for example.
Having a name specific to file btrees was also useful for naming/
documenting things...

But the code savings are hard to shake a stick at:

            code          stack
  before:  33260           3024
  after:   32874 (-1.2%)   2952 (-2.4%)
This commit is contained in:
Christopher Haster
2024-01-09 14:57:23 -06:00
parent 7d8315a598
commit 60d52d6cef
2 changed files with 279 additions and 298 deletions
+271 -287
View File
File diff suppressed because it is too large Load Diff
+8 -11
View File
@@ -524,12 +524,13 @@ typedef struct lfsr_shrub {
lfs_size_t estimate;
} lfsr_shrub_t;
// the lfsr_ftree_t struct is a sort of proto-file
typedef struct lfsr_ftree {
// ftrees contain both an active tree and staging tree, to allow
// staging files during mdir compacts
typedef struct lfsr_file {
lfsr_openedmdir_t *next;
// files contain both an active tree and staging tree, to allow
// staging during mdir compacts
//
// navigating this union is a bit tricky, and relies on related
// navigating this union is a bit tricky, and relies on the related
// mdir's block:
//
// sign(size)=1, data.size==0 => bnull
@@ -538,19 +539,15 @@ typedef struct lfsr_ftree {
// sign(size)=0, data.block==mdir.block => bshrub
// sign(size)=0, data.block!=mdir.block => btree
//
lfsr_mdir_t mdir;
union {
lfs_soff_t size;
lfs_soff_t bsize;
lfsr_data_t bsprout;
lfsr_bptr_t bptr;
lfsr_shrub_t bshrub;
lfsr_btree_t btree;
} u, u_;
} lfsr_ftree_t;
typedef struct lfsr_file {
lfsr_openedmdir_t *next;
lfsr_mdir_t mdir;
lfsr_ftree_t ftree;
uint32_t flags;
lfs_off_t pos;