process_files on a slice
This commit is contained in:
parent
d878182c56
commit
ce92ec5e87
10
src/main.rs
10
src/main.rs
@ -219,7 +219,7 @@ fn split_vec<'a, T>(src: &'a [T], num: usize) -> Vec<&'a [T]> {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_files(files: Vec<PathBuf>) {
|
fn process_files(files: &&[PathBuf]) {
|
||||||
let zip_file = fs::File::open(BASE_FILENAME).unwrap();
|
let zip_file = fs::File::open(BASE_FILENAME).unwrap();
|
||||||
let zip_reader = io::BufReader::new(zip_file);
|
let zip_reader = io::BufReader::new(zip_file);
|
||||||
let mut archive = zip::ZipArchive::new(zip_reader).unwrap();
|
let mut archive = zip::ZipArchive::new(zip_reader).unwrap();
|
||||||
@ -264,13 +264,9 @@ fn main() -> Result<(), Box<std::error::Error>> {
|
|||||||
.collect();
|
.collect();
|
||||||
drop(archive);
|
drop(archive);
|
||||||
|
|
||||||
//split vector and iterate on it parts in parallel
|
// split vector and process its parts in parallel
|
||||||
split_vec(&source_files, rayon::current_num_threads())
|
split_vec(&source_files, rayon::current_num_threads())
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.for_each(|slice| {
|
.for_each(process_files);
|
||||||
let source_files_part = slice.to_vec();
|
|
||||||
process_files(source_files_part);
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user