Skip to content

Commit 9bc005a

Browse files
committed
Only iterate through runnables once
1 parent 3f8083f commit 9bc005a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

crates/ide/src/runnables.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,15 @@ mod tests {
567567
let mut runnables = analysis.runnables(position.file_id).unwrap();
568568
runnables.sort_by_key(|it| (it.nav.full_range.start(), it.nav.name.clone()));
569569

570-
let navigation_targets = runnables.iter().map(|a| a.nav.clone()).collect::<Vec<_>>();
571-
expect.assert_debug_eq(&navigation_targets);
570+
let mut navigation_targets = Vec::with_capacity(runnables.len());
571+
let mut test_kinds = Vec::with_capacity(runnables.len());
572+
for runnable in runnables {
573+
test_kinds.push(runnable.test_kind());
574+
navigation_targets.push(runnable.nav);
575+
}
572576

573-
assert_eq!(
574-
actions,
575-
runnables.into_iter().map(|it| it.test_kind()).collect::<Vec<_>>().as_slice()
576-
);
577+
expect.assert_debug_eq(&navigation_targets);
578+
assert_eq!(actions, test_kinds.as_slice());
577579
}
578580

579581
fn check_tests(ra_fixture: &str, expect: Expect) {

0 commit comments

Comments
 (0)