aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-29 13:15:07 +0000
committerGitHub <[email protected]>2020-12-29 13:15:07 +0000
commit343029fa9e52cf4aae7f17ed6e0e6b5b0175a172 (patch)
tree004195234e0409ddc54514a2e8b737ed8e16b74e /crates/ide_db
parentef1177c5b5a7ced9866025a51c10e4375e2a37fd (diff)
parent42c24ff25f391a1e3662ce226d510aedc9d1f0e4 (diff)
Merge #7077
7077: Avoid a couple of allocations r=Veykril a=lnicola r? @Veykril TBH I'm not sure this is worth it, but the other `Query` was already taking a `String`. Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/imports_locator.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs
index b6355af4b..0f4c2ca47 100644
--- a/crates/ide_db/src/imports_locator.rs
+++ b/crates/ide_db/src/imports_locator.rs
@@ -15,14 +15,14 @@ use rustc_hash::FxHashSet;
15pub fn find_exact_imports<'a>( 15pub fn find_exact_imports<'a>(
16 sema: &Semantics<'a, RootDatabase>, 16 sema: &Semantics<'a, RootDatabase>,
17 krate: Crate, 17 krate: Crate,
18 name_to_import: &str, 18 name_to_import: String,
19) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { 19) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
20 let _p = profile::span("find_exact_imports"); 20 let _p = profile::span("find_exact_imports");
21 find_imports( 21 find_imports(
22 sema, 22 sema,
23 krate, 23 krate,
24 { 24 {
25 let mut local_query = symbol_index::Query::new(name_to_import.to_string()); 25 let mut local_query = symbol_index::Query::new(name_to_import.clone());
26 local_query.exact(); 26 local_query.exact();
27 local_query.limit(40); 27 local_query.limit(40);
28 local_query 28 local_query
@@ -39,18 +39,18 @@ pub fn find_similar_imports<'a>(
39 sema: &Semantics<'a, RootDatabase>, 39 sema: &Semantics<'a, RootDatabase>,
40 krate: Crate, 40 krate: Crate,
41 limit: Option<usize>, 41 limit: Option<usize>,
42 fuzzy_search_string: &str, 42 fuzzy_search_string: String,
43 name_only: bool, 43 name_only: bool,
44) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { 44) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
45 let _p = profile::span("find_similar_imports"); 45 let _p = profile::span("find_similar_imports");
46 46
47 let mut external_query = 47 let mut external_query = import_map::Query::new(fuzzy_search_string.clone())
48 import_map::Query::new(fuzzy_search_string).search_mode(import_map::SearchMode::Fuzzy); 48 .search_mode(import_map::SearchMode::Fuzzy);
49 if name_only { 49 if name_only {
50 external_query = external_query.name_only(); 50 external_query = external_query.name_only();
51 } 51 }
52 52
53 let mut local_query = symbol_index::Query::new(fuzzy_search_string.to_string()); 53 let mut local_query = symbol_index::Query::new(fuzzy_search_string);
54 54
55 if let Some(limit) = limit { 55 if let Some(limit) = limit {
56 local_query.limit(limit); 56 local_query.limit(limit);