Dropped the file.size field

While convenient, file.size is redundant info. Redundant info always
has the risk of falling out-of-sync, creating difficult to find bugs.

This was made especially apparent with dropping file-level idempotent
errors, which make possible file states quite a bit more complex (we've
given up on fully reverting errors, but we don't want errors to make the
filesystem inconsistent).

Replacing file.size with an inlinable function that derives the file
size removes this risk without too much cost. As a plus, lfsr_file_t is
one word smaller:

            code          stack          lfsr_file_t
  before:  33286           2968                  112
  after:   33278 (-0.0%)   2976 (+0.3%)          108 (-3.6%)
This commit is contained in:
Christopher Haster
2024-01-07 12:28:25 -06:00
parent ebddafd66f
commit 07e9bbf5b7
2 changed files with 85 additions and 103 deletions
-1
View File
@@ -554,7 +554,6 @@ typedef struct lfsr_file {
lfsr_ftree_t ftree;
uint32_t flags;
lfs_off_t pos;
lfs_off_t size;
lfs_off_t buffer_pos;
uint8_t *buffer;