Skip to content

Commit

Permalink
Adopted redundant cache read in lfs_file_relocate
Browse files Browse the repository at this point in the history
Previously had some custom logic that could be reduced
  • Loading branch information
geky committed Jun 29, 2017
1 parent 0e1022a commit 931442a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,14 +1207,10 @@ static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) {
// either read from dirty cache or disk
for (lfs_off_t i = 0; i < file->off; i++) {
uint8_t data;
if (file->cache.block == file->block && i >= file->cache.off) {
data = file->cache.buffer[i - file->cache.off];
} else {
// just read from disk
err = lfs_bd_read(lfs, file->block, i, &data, 1);
if (err) {
return err;
}
err = lfs_cache_read(lfs, &lfs->rcache, &file->cache,
file->block, i, &data, 1);
if (err) {
return err;
}

err = lfs_cache_prog(lfs, &lfs->pcache, &lfs->rcache,
Expand Down

0 comments on commit 931442a

Please sign in to comment.