File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5858 let children = children
5959 . into_iter ( )
6060 . pipe ( Chunks :: < 64 , _ > :: new)
61+ . par_bridge ( )
6162 . map ( |names : Vec < _ > | -> Vec < _ > {
6263 names
6364 . into_par_iter ( )
7172 . map ( Self :: from)
7273 . collect ( )
7374 } )
74- . fold ( Vec :: new ( ) , |mut a, b| {
75- a. extend ( b) ;
76- a
77- } ) ;
75+ . reduce ( Vec :: new, add_short_vec_to_long) ;
7876
7977 if max_depth > 0 {
8078 DataTree :: dir ( name, size, children)
8583 }
8684}
8785
86+ /// Concat 2 `Vec`s in any order with minimal copying.
87+ fn add_short_vec_to_long < Item > ( mut a : Vec < Item > , mut b : Vec < Item > ) -> Vec < Item > {
88+ if a. len ( ) > b. len ( ) {
89+ a. extend ( b) ;
90+ a
91+ } else {
92+ b. extend ( a) ;
93+ b
94+ }
95+ }
96+
8897/// Utility type to iterate over each `Vec` of at most `LEN` items.
8998#[ derive( Debug , Clone , Copy ) ]
9099struct Chunks < const LEN : usize , Iter > {
You can’t perform that action at this time.
0 commit comments