Skip to content

Commit 919ecc6

Browse files
committed
Use HashSet to enhance performance in for_unique_generic_name in suggest_name
1 parent bc1a577 commit 919ecc6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

crates/ide-assists/src/utils/suggest_name.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This module contains functions to suggest names for expressions, functions and other items
22
3+
use std::collections::HashSet;
4+
35
use hir::Semantics;
46
use ide_db::RootDatabase;
57
use itertools::Itertools;
@@ -76,12 +78,9 @@ pub(crate) fn for_unique_generic_name(
7678
ast::GenericParam::TypeParam(t) => t.name().unwrap().to_string(),
7779
p => p.to_string(),
7880
})
79-
.collect_vec();
81+
.collect::<HashSet<_>>();
8082
let mut name = name.to_string();
8183
let base_len = name.len();
82-
// 4*len bytes for base, and 2 bytes for 2 digits
83-
name.reserve(4 * base_len + 2);
84-
8584
let mut count = 0;
8685
while param_names.contains(&name) {
8786
name.truncate(base_len);

0 commit comments

Comments
 (0)