rust: no alocar por archivos que no se van a comprimir

This commit is contained in:
Cat /dev/Nulo 2023-04-24 20:10:54 -03:00
parent bade1e4913
commit 1f60324e83

View file

@ -121,15 +121,15 @@ fn iterator(input: &Path) -> impl Iterator<Item = PathBuf> {
.into_iter() .into_iter()
.filter_map(|e| e.ok()) .filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file()) .filter(|e| e.file_type().is_file())
.filter(|e| !already_compressed(e.path()))
.map(|e| e.path().to_owned()) .map(|e| e.path().to_owned())
.filter(|e| !already_compressed(e))
} }
fn strip_input(path: &Path, input: &Path) -> PathBuf { fn strip_input(path: &Path, input: &Path) -> PathBuf {
path.strip_prefix(input).unwrap().to_owned() path.strip_prefix(input).unwrap().to_owned()
} }
fn already_compressed(path: &PathBuf) -> bool { fn already_compressed(path: &Path) -> bool {
let p = path.to_string_lossy(); let p = path.to_string_lossy();
p.ends_with(".br") || p.ends_with(".gz") p.ends_with(".br") || p.ends_with(".gz")
} }