Skip to content

Commit 756c19c

Browse files
committed
cleanup
- Bail early when we know nothing changed - Remove unnecessary `.clone()` calls - Use `metadata` on `path` directly
1 parent 24ccca3 commit 756c19c

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

  • crates/oxide/src/scanner

crates/oxide/src/scanner/mod.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,19 @@ impl Scanner {
382382

383383
for (path, is_dir, extension) in all_entries {
384384
if is_dir {
385-
self.dirs.insert(path.clone());
385+
self.dirs.insert(path);
386386
} else {
387387
// Deduplicate: parallel walk can visit the same file from multiple threads
388388
if !self.files.insert(path.clone()) {
389389
continue;
390390
}
391+
self.extensions.insert(extension.clone());
391392

392393
// On re-scans, check mtime to skip unchanged files.
393394
// On the first scan we skip this entirely to avoid extra
394395
// metadata syscalls.
395396
let changed = if self.has_scanned_once {
396-
let current_mtime = std::fs::metadata(&path)
397-
.ok()
398-
.and_then(|m| m.modified().ok());
397+
let current_mtime = path.metadata().ok().and_then(|m| m.modified().ok());
399398

400399
match current_mtime {
401400
Some(mtime) => {
@@ -408,22 +407,16 @@ impl Scanner {
408407
true
409408
};
410409

410+
if !changed {
411+
continue;
412+
}
413+
411414
match extension.as_str() {
412415
// Special handing for CSS files, we don't want to extract candidates from
413416
// these files, but we do want to extract used CSS variables.
414-
"css" => {
415-
if changed {
416-
css_files.push(path.clone());
417-
}
418-
}
419-
_ => {
420-
if changed {
421-
content_paths.push((path.clone(), extension.clone()));
422-
}
423-
}
417+
"css" => css_files.push(path),
418+
_ => content_paths.push((path, extension)),
424419
}
425-
426-
self.extensions.insert(extension);
427420
}
428421
}
429422

0 commit comments

Comments
 (0)