11use super :: utils;
2+ use rayon:: prelude:: * ;
23use std:: collections:: HashMap ;
34use std:: fs;
45use std:: io:: { BufRead , BufReader , ErrorKind } ;
@@ -122,8 +123,9 @@ pub fn scandir(index: &mut Index, basedir: &Path, directory: &Path) {
122123pub fn make_file_hashes ( index : & mut Index ,
123124 directory : & Path , indexfile : & IndexFile , args : & utils:: Args ) {
124125
125- for subindex in index. values_mut ( ) {
126- for record in subindex {
126+ index. par_iter_mut ( )
127+ . flat_map ( |( _, subindex) | subindex. par_iter_mut ( ) )
128+ . for_each ( |record| {
127129 if ! args. paranoid {
128130 let path = record. path . to_path_buf ( ) . into_os_string ( ) . into_vec ( ) ;
129131 let filerecord = indexfile. get ( & path) ;
@@ -141,11 +143,10 @@ pub fn make_file_hashes(index: &mut Index,
141143
142144 let f = match fs:: File :: open ( & path) {
143145 Ok ( f) => f,
144- Err ( ref err) if err. kind ( ) == ErrorKind :: PermissionDenied
145- => continue ,
146+ Err ( ref err) if err. kind ( ) == ErrorKind :: PermissionDenied => return ,
146147 Err ( err) => {
147148 eprintln ! ( "Warning: skipping {}: {err}" , path. display( ) ) ;
148- continue ;
149+ return ;
149150 }
150151 } ;
151152 let mut reader = BufReader :: with_capacity ( 32768 , f) ;
@@ -181,8 +182,7 @@ pub fn make_file_hashes(index: &mut Index,
181182 }
182183 }
183184 }
184- }
185- }
185+ } ) ;
186186}
187187
188188fn make_links ( linkindex : & [ IdxRecord ] , directory : & Path , args : & utils:: Args ) -> u64 {
0 commit comments