Reused block_start/end in crystallize math

Not sure how the duplication here went unnoticed.

Note we can _not_ reuse block_start/end for the buffer updates, since
those depend on the crystallized/aligned result.

No code changes though. The good news is the compiler is doing a good
job with the dense math in these functions.
This commit is contained in:
Christopher Haster
2025-05-23 23:12:54 -05:00
parent 8316fbdfd1
commit b9ef43a30e
+11 -14
View File
@@ -12418,8 +12418,7 @@ static int lfsr_file_crystallize(lfs_t *lfs, lfsr_file_t *file) {
// finish crystallizing the block
int err = lfsr_file_crystallize_(lfs, file,
file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr),
-1, -1,
file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr), -1, -1,
file->cache.pos, file->cache.buffer, file->cache.size);
if (err) {
return err;
@@ -12482,11 +12481,9 @@ static int lfsr_file_flush_(lfs_t *lfs, lfsr_file_t *file,
// need to bail if we can't meet prog alignment
&& (pos + size) - block_end >= lfs->cfg->prog_size) {
int err = lfsr_file_crystallize_(lfs, file,
file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr),
(pos + size)
- (file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr)),
(pos + size)
- (file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr)),
block_start,
(pos + size) - block_start,
(pos + size) - block_start,
pos, buffer, size);
if (err) {
return err;
@@ -12612,11 +12609,9 @@ static int lfsr_file_flush_(lfs_t *lfs, lfsr_file_t *file,
&& crystal_start >= block_end
&& crystal_start < block_start + lfs->cfg->block_size) {
int err = lfsr_file_crystallize_(lfs, file,
file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr),
crystal_end
- (file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr)),
crystal_end
- (file->leaf.pos - lfsr_bptr_off(&file->leaf.bptr)),
block_start,
crystal_end - block_start,
crystal_end - block_start,
pos, buffer, size);
if (err) {
return err;
@@ -12684,8 +12679,10 @@ static int lfsr_file_flush_(lfs_t *lfs, lfsr_file_t *file,
// start crystallizing!
//
// lfsr_file_crystallize_ handles block allocation/relocation
err = lfsr_file_crystallize_(lfs, file, crystal_start,
crystal_end - crystal_start, crystal_end - crystal_start,
err = lfsr_file_crystallize_(lfs, file,
crystal_start,
crystal_end - crystal_start,
crystal_end - crystal_start,
pos, buffer, size);
if (err) {
return err;