update output condition check to use .map
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by knidarkness · committed by David Peter · parent 34eb150 · Browse files · 1 file·+16 added−26 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+16 added−26 removed
- other:+16 added−26 removed
Provenance
- Commit
b3084cb- Tree
702996d- Author
knidarkness <knidarkness@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
34eb150
1 file changed+16 added−26 removed
modified:src/hyperfine/benchmark.rs+16 added-26 removed
139 unmodified lines140 times_user.push(r.time_user);141 times_system.push(r.time_system);142 }143 }144- if let Some(ref bar) = progress_bar {145- bar.inc(1);146- }144+145+ progress_bar.as_ref().map(|bar| bar.inc(1));146 }148- if let Some(ref bar) = progress_bar {149- bar.finish_and_clear();150- }147 148+ progress_bar.as_ref().map(|bar| bar.finish_and_clear());149+ 150 Ok(TimingResult {151 time_real: mean(×_real),152 time_user: mean(×_user),153 time_system: mean(×_system),96 unmodified lines250 options.show_output,251 options.failure_action,252 None,253 )?;256- if let Some(ref pbar) = progress_bar {257- pbar.inc(1);258- }254+ progress_bar.as_ref().map(|bar| bar.inc(1));255+ 256 }260- if let Some(ref bar) = progress_bar {261- bar.finish_and_clear();262- }257+ progress_bar.as_ref().map(|bar| bar.finish_and_clear());258+ 259 }260 261 // Set up progress bar (and spinner for initial measurement)262 let progress_bar = if options.output_style != OutputStyleOption::Disabled {42 unmodified lines305 306 all_succeeded = all_succeeded && success;307 308 // Re-configure the progress bar313- if let Some(ref bar) = progress_bar {314- bar.set_length(count);315- bar.inc(1);316- }317-309+ progress_bar.as_ref().map(|bar| bar.set_length(count));310+ progress_bar.as_ref().map(|bar| bar.inc(1));311+ 312 // Gather statistics313 for _ in 0..count_remaining {314 run_preparation_command(&options.shell, &prepare_cmd, options.show_output)?;315 1 unmodified line317 let mean = format_duration(mean(×_real), options.time_unit);318 format!("Current estimate: {}", mean.to_string().green())319 };320 327- if let Some(ref bar) = progress_bar {328- bar.set_message(&msg);329- }321+ progress_bar.as_ref().map(|bar| bar.set_message(&msg));322 323 let (res, success) = time_shell_command(324 &options.shell,325 cmd,7 unmodified lines333 times_system.push(res.time_system);334 335 all_succeeded = all_succeeded && success;336 345- if let Some(ref bar) = progress_bar {346- bar.inc(1);347- }337+ progress_bar.as_ref().map(|bar| bar.inc(1));338 }349- if let Some(ref bar) = progress_bar {350- bar.finish_and_clear();351- }339 340+ progress_bar.as_ref().map(|bar| bar.finish_and_clear());341+342+343 // Compute statistical quantities344 let t_num = times_real.len();345 let t_mean = mean(×_real);346 let t_stddev = standard_deviation(×_real, Some(t_mean));95 unmodified lines