From 5a943c33eabff4102c1ded4c35d411af99de5ab4 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 19 Feb 2026 02:27:36 -0600 Subject: [PATCH] Refactor prefetch_project_files function for improved readability - Simplified the iteration over directory entries in the `prefetch_project_files` function by using `into_iter().flatten()` instead of a nested loop. - This change enhances code clarity while maintaining the existing functionality of collecting valid directory entries. These modifications aim to streamline the code and improve maintainability in the prefetching process. --- src/serve_session.rs | 6 ++---- src/snapshot_middleware/dir.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/serve_session.rs b/src/serve_session.rs index 6c6f3d78..c990ac80 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -152,10 +152,8 @@ fn prefetch_project_files(project: &Project) -> io::Result { if !root.exists() { continue; } - for entry in WalkDir::new(root).follow_links(true) { - if let Ok(e) = entry { - entries.push(e); - } + for e in WalkDir::new(root).follow_links(true).into_iter().flatten() { + entries.push(e); } } diff --git a/src/snapshot_middleware/dir.rs b/src/snapshot_middleware/dir.rs index 1c5e92df..a19fbdd5 100644 --- a/src/snapshot_middleware/dir.rs +++ b/src/snapshot_middleware/dir.rs @@ -472,7 +472,7 @@ mod test { .unwrap(); fn count_nodes(snap: &InstanceSnapshot) -> usize { - 1 + snap.children.iter().map(|c| count_nodes(c)).sum::() + 1 + snap.children.iter().map(count_nodes).sum::() } let total = count_nodes(&snap); assert!(total > 100, "Should have many nodes, got {total}");