From 2349ac8c96f719ce44b38114ffcc1f6b058b8159 Mon Sep 17 00:00:00 2001 From: ryancw <1831931681@qq.com> Date: Wed, 28 May 2025 10:23:47 +0800 Subject: [PATCH 1/2] perf: gc might try to populate the lookahead buffer each time --- lfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index c0b0ba3..cec4870 100644 --- a/lfs.c +++ b/lfs.c @@ -5225,7 +5225,7 @@ static int lfs_fs_gc_(lfs_t *lfs) { } // try to populate the lookahead buffer, unless it's already full - if (lfs->lookahead.size < 8*lfs->cfg->lookahead_size) { + if (lfs->lookahead.size < lfs_min(8 * lfs->cfg->lookahead_size, lfs->block_count)) { err = lfs_alloc_scan(lfs); if (err) { return err; From d5a86fd28de74dd1d5a6126d843b16276e6023cf Mon Sep 17 00:00:00 2001 From: ryancw <1831931681@qq.com> Date: Tue, 3 Jun 2025 09:46:59 +0800 Subject: [PATCH 2/2] style: format code, limit to 80 columns. --- lfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index cec4870..1126b2a 100644 --- a/lfs.c +++ b/lfs.c @@ -5225,7 +5225,9 @@ static int lfs_fs_gc_(lfs_t *lfs) { } // try to populate the lookahead buffer, unless it's already full - if (lfs->lookahead.size < lfs_min(8 * lfs->cfg->lookahead_size, lfs->block_count)) { + if (lfs->lookahead.size < lfs_min( + 8 * lfs->cfg->lookahead_size, + lfs->block_count)) { err = lfs_alloc_scan(lfs); if (err) { return err;