Reverted to separately tracked dir pos/bookmark mdirs

This is just too enticing a simplification to avoid, even at a RAM cost.

By tracking the dir's bookmark as a separate mdir, we can trivially
deduplicate the logic to update dirs' mdirs. But this does significantly
increase the size of our lfsr_dir_t with the bookmark's type/flags/rbyd/
etc, which usually goes unused.

I guess this does optimize lfsr_dir_rewind... Is that ever a bottleneck?

Code changes:

            code          stack          lfsr_dir_t
  before:  34048           2944                  48
  after:   33956 (-0.3%)   2944 (+0.0%)          80 (+66.7%)
This commit is contained in:
Christopher Haster
2024-01-19 01:39:46 -06:00
parent 76ccefcc84
commit d2a6a6ee2f
2 changed files with 49 additions and 85 deletions
+7 -8
View File
@@ -116,8 +116,11 @@ enum lfs_error {
// File types
enum lfs_type {
// file types
LFS_TYPE_REG = 1,
LFS_TYPE_DIR = 2,
LFS_TYPE_REG = 1,
LFS_TYPE_DIR = 2,
// internally used types
LFS_TYPE_BOOKMARK = 4,
};
// File open flags
@@ -449,13 +452,9 @@ typedef struct lfs_dir {
} lfs_dir_t;
typedef struct lfsr_dir {
struct lfsr_opened *next;
uint8_t type;
uint16_t flags; // unused
lfsr_mdir_t mdir;
lfsr_opened_t p; // pos mdir
lfsr_opened_t b; // bookmark mdir
lfsr_did_t did;
lfsr_smid_t bookmark;
lfs_soff_t pos;
} lfsr_dir_t;