@@ -9,7 +9,6 @@ use std::collections::HashMap;
9
9
use std:: fmt:: Debug ;
10
10
use std:: fs;
11
11
use std:: option:: Option ;
12
- use std:: sync:: { Arc , Mutex } ;
13
12
use style:: options:: { SortOrder , StyleSortGroupKey , StyleSorting } ;
14
13
#[ allow( unused_imports) ] // for now
15
14
use style:: template:: {
@@ -387,24 +386,22 @@ impl Processor {
387
386
let refs = self . get_references ( ) ;
388
387
let sorted_refs = self . sort_references ( refs) ;
389
388
let grouped_refs = self . group_references ( sorted_refs) ;
390
- // REVIEW would prefer to avoid using mutable varibles here
391
- let proc_hints = Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ;
392
- for ( key, group) in grouped_refs {
393
- let group_len = group. len ( ) ;
394
- // Run the processing in parallel.
395
- group. into_par_iter ( ) . enumerate ( ) . for_each ( |( index, reference) | {
396
- let proc_hint = ProcHints {
397
- disamb_condition : false ,
398
- group_index : index + 1 ,
399
- group_length : group_len,
400
- group_key : key. clone ( ) ,
401
- } ;
402
- let id = reference. id . as_ref ( ) . unwrap ( ) . clone ( ) ;
403
- let mut proc_hints = proc_hints. lock ( ) . unwrap ( ) ;
404
- proc_hints. insert ( id, proc_hint) ;
405
- } ) ;
406
- }
407
- Arc :: try_unwrap ( proc_hints) . unwrap ( ) . into_inner ( ) . unwrap ( )
389
+ let proc_hints = grouped_refs
390
+ . iter ( )
391
+ . flat_map ( |( key, group) | {
392
+ let group_len = group. len ( ) ;
393
+ group. iter ( ) . enumerate ( ) . map ( move |( index, reference) | {
394
+ let proc_hint = ProcHints {
395
+ disamb_condition : false ,
396
+ group_index : index + 1 ,
397
+ group_length : group_len,
398
+ group_key : key. clone ( ) ,
399
+ } ;
400
+ ( reference. id . as_ref ( ) . unwrap ( ) . clone ( ) , proc_hint)
401
+ } )
402
+ } )
403
+ . collect ( ) ;
404
+ proc_hints
408
405
}
409
406
410
407
/// Return a string to use for grouping for a given reference, using instructions in the style.
0 commit comments