File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -459,13 +459,18 @@ impl<S> ThreadPoolBuilder<S> {
459459 if self . num_threads > 0 {
460460 self . num_threads
461461 } else {
462+ let default = || {
463+ thread:: available_parallelism ( )
464+ . map ( |n| n. get ( ) )
465+ . unwrap_or ( 1 )
466+ } ;
467+
462468 match env:: var ( "RAYON_NUM_THREADS" )
463469 . ok ( )
464470 . and_then ( |s| usize:: from_str ( & s) . ok ( ) )
465471 {
466- Some ( x) if x > 0 => return x,
467- Some ( x) if x == 0 => return thread:: available_parallelism ( )
468- . map ( |n| n. get ( ) ) . unwrap_or ( 1 ) ,
472+ Some ( x @ 1 ..) => return x,
473+ Some ( 0 ) => return default ( ) ,
469474 _ => { }
470475 }
471476
@@ -474,8 +479,8 @@ impl<S> ThreadPoolBuilder<S> {
474479 . ok ( )
475480 . and_then ( |s| usize:: from_str ( & s) . ok ( ) )
476481 {
477- Some ( x) if x > 0 => x,
478- _ => thread :: available_parallelism ( ) . map ( |n| n . get ( ) ) . unwrap_or ( 1 )
482+ Some ( x @ 1 .. ) => x,
483+ _ => default ( ) ,
479484 }
480485 }
481486 }
You can’t perform that action at this time.
0 commit comments