@@ -476,25 +476,26 @@ impl<'a> ParWalker<'a> {
476476 let t_active = start_time. elapsed ( ) ;
477477
478478 if let Some ( limit) = cpu_limit
479- && limit < 100 {
480- // Calculate the required sleep duration to limit
481- // CPU usage to the target percentage.
482- //
483- // Let T_active be the elapsed time scanning the
484- // file. Let T_sleep be the sleep time. The target
485- // utilization percentage is P.
486- //
487- // P = 100 * T_active / (T_active + T_sleep)
488- // P * (T_active + T_sleep) = 100 * T_active
489- // P * T_sleep = ( 100 - P) * T_active
490- // T_sleep = T_active * (100 - P) / P
491- let t_sleep = t_active . mul_f64 (
492- ( 100.0 - limit as f64 ) / limit as f64 ,
493- ) ;
494- if !t_sleep . is_zero ( ) {
495- thread :: sleep ( t_sleep) ;
496- }
479+ && limit < 100
480+ {
481+ // Calculate the required sleep duration to limit
482+ // CPU usage to the target percentage.
483+ //
484+ // Let T_active be the elapsed time scanning the
485+ // file. Let T_sleep be the sleep time. The target
486+ // utilization percentage is P.
487+ //
488+ // P = 100 * T_active / (T_active + T_sleep)
489+ // P * (T_active + T_sleep) = 100 * T_active
490+ // P * T_sleep = (100 - P) * T_active
491+ // T_sleep = T_active * (100 - P) / P
492+ let t_sleep = t_active . mul_f64 (
493+ ( 100.0 - limit as f64 ) / limit as f64 ,
494+ ) ;
495+ if ! t_sleep. is_zero ( ) {
496+ thread :: sleep ( t_sleep ) ;
497497 }
498+ }
498499
499500 if let Err ( err) = res
500501 && error ( err, & msg_send) . is_err ( )
0 commit comments