Remove unnecessary path & pathbuf code

This commit is contained in:
bootandy
2018-05-02 00:42:03 +01:00
parent dba465a094
commit 3e9f09e339
+4 -7
View File
@@ -4,9 +4,6 @@ use std::collections::HashSet;
use walkdir::WalkDir; use walkdir::WalkDir;
use std::path::Path;
use std::path::PathBuf;
mod platform; mod platform;
use self::platform::*; use self::platform::*;
@@ -22,7 +19,7 @@ pub fn get_dir_tree(
for b in filenames { for b in filenames {
let top_level_name = strip_end_slashes(b); let top_level_name = strip_end_slashes(b);
examine_dir( examine_dir(
&Path::new(&top_level_name).to_path_buf(), &top_level_name,
apparent_size, apparent_size,
&mut inodes, &mut inodes,
&mut data, &mut data,
@@ -42,7 +39,7 @@ fn strip_end_slashes(s: &str) -> String {
} }
fn examine_dir( fn examine_dir(
top_dir: &PathBuf, top_dir: &String,
apparent_size: bool, apparent_size: bool,
inodes: &mut HashSet<(u64, u64)>, inodes: &mut HashSet<(u64, u64)>,
data: &mut HashMap<String, u64>, data: &mut HashMap<String, u64>,
@@ -66,9 +63,9 @@ fn examine_dir(
let mut e_path = e.path().to_path_buf(); let mut e_path = e.path().to_path_buf();
loop { loop {
let path_name = e_path.to_string_lossy().to_string(); let path_name = e_path.to_string_lossy().to_string();
let s = data.entry(path_name).or_insert(0); let s = data.entry(path_name.clone()).or_insert(0);
*s += size; *s += size;
if e_path == *top_dir { if path_name == *top_dir {
break; break;
} }
e_path.pop(); e_path.pop();