Skip to content

Commit 8e251dd

Browse files
authored
Merge pull request #1110 from Ryan-CW-Code/perf_gc
perf: gc might try to populate the lookahead buffer each time
2 parents 25b9a4a + d5a86fd commit 8e251dd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lfs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5222,7 +5222,9 @@ static int lfs_fs_gc_(lfs_t *lfs) {
52225222
}
52235223

52245224
// try to populate the lookahead buffer, unless it's already full
5225-
if (lfs->lookahead.size < 8*lfs->cfg->lookahead_size) {
5225+
if (lfs->lookahead.size < lfs_min(
5226+
8 * lfs->cfg->lookahead_size,
5227+
lfs->block_count)) {
52265228
err = lfs_alloc_scan(lfs);
52275229
if (err) {
52285230
return err;

0 commit comments

Comments
 (0)