mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
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.
This commit is contained in:
parent
0462b91a6c
commit
5a943c33ea
2 changed files with 3 additions and 5 deletions
|
|
@ -152,12 +152,10 @@ fn prefetch_project_files(project: &Project) -> io::Result<PrefetchCache> {
|
|||
if !root.exists() {
|
||||
continue;
|
||||
}
|
||||
for entry in WalkDir::new(root).follow_links(true) {
|
||||
if let Ok(e) = entry {
|
||||
for e in WalkDir::new(root).follow_links(true).into_iter().flatten() {
|
||||
entries.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also include the project file itself (read by project middleware).
|
||||
if let Ok(meta) = std::fs::metadata(&project.file_location) {
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ mod test {
|
|||
.unwrap();
|
||||
|
||||
fn count_nodes(snap: &InstanceSnapshot) -> usize {
|
||||
1 + snap.children.iter().map(|c| count_nodes(c)).sum::<usize>()
|
||||
1 + snap.children.iter().map(count_nodes).sum::<usize>()
|
||||
}
|
||||
let total = count_nodes(&snap);
|
||||
assert!(total > 100, "Should have many nodes, got {total}");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue