mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-09-04 14:35:32 +00:00
perf: unwrap the size once
This commit is contained in:
@@ -152,7 +152,8 @@ pub fn print(duplicates: DashMap<String, Vec<File>>, opts: &Params) {
|
||||
let size =
|
||||
f.1.first()
|
||||
.and_then(|ff| fs::metadata(&ff.path).ok())
|
||||
.and_then(|m| Some(m.len()));
|
||||
.and_then(|m| Some(m.len()))
|
||||
.unwrap_or_default();
|
||||
(f.0, f.1, size)
|
||||
})
|
||||
.sorted_unstable_by_key(|f| f.2) // sort by ascending size
|
||||
@@ -164,7 +165,7 @@ pub fn print(duplicates: DashMap<String, Vec<File>>, opts: &Params) {
|
||||
format_path(&file.path, opts).unwrap_or_default().blue(),
|
||||
// since all files should logically have the same size,
|
||||
// we can print the pre-computed size of the first element in the group
|
||||
format!("{:>12}", format_size(size.unwrap_or_default(), DECIMAL)).red(),
|
||||
format!("{:>12}", format_size(size, DECIMAL)).red(),
|
||||
modified_time(&file.path).unwrap_or_default().yellow()
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user