Skip to content

Commit

Permalink
Use 'if' instead of 'match'
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Oct 13, 2019
1 parent ea2d622 commit 92e59c3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/hyperfine/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,14 @@ pub fn run_benchmark(

// Run init command
let prepare_cmd = options.preparation_command.as_ref().map(|values| {
let corresponding_prepare_cmd = match values.len() {
1 => &values[0],
_ => &values[num],
let preparation_command = if values.len() == 1 {
&values[0]
} else {
&values[num]
};
match cmd.get_parameter() {
Some((param, value)) => {
Command::new_parametrized(corresponding_prepare_cmd, param, value)
}
None => Command::new(corresponding_prepare_cmd),
Some((param, value)) => Command::new_parametrized(preparation_command, param, value),
None => Command::new(preparation_command),
}
});

Expand Down

0 comments on commit 92e59c3

Please sign in to comment.