@@ -588,28 +588,41 @@ pub fn run(clap_config: &ArgMatches) {
588
588
. flatten ( )
589
589
. collect ( )
590
590
} else {
591
- let counter = std:: sync:: atomic:: AtomicUsize :: new ( 0 ) ;
592
-
593
- // Ask rayon for thread count. Assume that half of that is the number of physical cores
594
- // Use one target dir for each core so that we can run N clippys in parallel.
595
- // We need to use different target dirs because cargo would lock them for a single build otherwise,
596
- // killing the parallelism. However this also means that deps will only be reused half/a
597
- // quarter of the time which might result in a longer wall clock runtime
598
-
599
- // This helps when we check many small crates with dep-trees that don't have a lot of branches in
600
- // order to achive some kind of parallelism
601
-
602
- // by default, use a single thread
603
- let num_cpus = config. max_jobs ;
604
- let num_crates = crates. len ( ) ;
605
-
606
- // check all crates (default)
607
- crates
608
- . into_par_iter ( )
609
- . map ( |krate| krate. download_and_extract ( ) )
610
- . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & counter, num_cpus, num_crates) )
611
- . flatten ( )
612
- . collect ( )
591
+ if config. max_jobs > 1 {
592
+ // run parallel with rayon
593
+
594
+ let counter = AtomicUsize :: new ( 0 ) ;
595
+
596
+ // Ask rayon for thread count. Assume that half of that is the number of physical cores
597
+ // Use one target dir for each core so that we can run N clippys in parallel.
598
+ // We need to use different target dirs because cargo would lock them for a single build otherwise,
599
+ // killing the parallelism. However this also means that deps will only be reused half/a
600
+ // quarter of the time which might result in a longer wall clock runtime
601
+
602
+ // This helps when we check many small crates with dep-trees that don't have a lot of branches in
603
+ // order to achive some kind of parallelism
604
+
605
+ // by default, use a single thread
606
+ let num_cpus = config. max_jobs ;
607
+ let num_crates = crates. len ( ) ;
608
+
609
+ // check all crates (default)
610
+ crates
611
+ . into_par_iter ( )
612
+ . map ( |krate| krate. download_and_extract ( ) )
613
+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & counter, num_cpus, num_crates) )
614
+ . flatten ( )
615
+ . collect ( )
616
+ } else {
617
+ // run sequential
618
+ let num_crates = crates. len ( ) ;
619
+ crates
620
+ . into_iter ( )
621
+ . map ( |krate| krate. download_and_extract ( ) )
622
+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path, & AtomicUsize :: new ( 0 ) , 1 , num_crates) )
623
+ . flatten ( )
624
+ . collect ( )
625
+ }
613
626
} ;
614
627
615
628
// generate some stats
0 commit comments