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
|
||||
}
|
||||
|
||||
fn process_files(files: Vec<PathBuf>) {
|
||||
fn process_files(files: &&[PathBuf]) {
|
||||
let zip_file = fs::File::open(BASE_FILENAME).unwrap();
|
||||
let zip_reader = io::BufReader::new(zip_file);
|
||||
let mut archive = zip::ZipArchive::new(zip_reader).unwrap();
|
||||
@ -264,13 +264,9 @@ fn main() -> Result<(), Box<std::error::Error>> {
|
||||
.collect();
|
||||
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())
|
||||
.par_iter()
|
||||
.for_each(|slice| {
|
||||
let source_files_part = slice.to_vec();
|
||||
process_files(source_files_part);
|
||||
});
|
||||
|
||||
.for_each(process_files);
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user