mirror of
https://gitee.com/openharmony/third_party_littlefs
synced 2024-11-23 14:59:50 +00:00
Adopted redundant cache read in lfs_file_relocate
Previously had some custom logic that could be reduced
This commit is contained in:
parent
0e1022a86c
commit
931442a784
12
lfs.c
12
lfs.c
@ -1207,14 +1207,10 @@ relocate:
|
||||
// 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,
|
||||
|
Loading…
Reference in New Issue
Block a user