Skip to content

Commit

Permalink
Use retain instead of filter for efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat authored and sagacity committed Oct 6, 2022
1 parent baea585 commit 18ced63
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions mos/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@ pub fn test_command(args: &Args, root: &Path, cfg: &Config) -> MosResult<i32> {
let mut test_cases = enumerate_test_cases(src.clone(), &input_path)?;

if let Some(test_name) = &cfg.test.name {
test_cases = test_cases
.into_iter()
.filter(|(_, c)| &c.to_string() == test_name)
.collect();
test_cases.retain(|(_, c)| &c.to_string() == test_name);
}
if let Some(test_filter) = &cfg.test.filter {
test_cases = test_cases
.into_iter()
.filter(|(_, c)| c.to_string().contains(test_filter))
.collect();
test_cases.retain(|(_, c)| c.to_string().contains(test_filter));
}

let mut failed = vec![];
Expand Down

0 comments on commit 18ced63

Please sign in to comment.