aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-12-08 12:38:43 +0000
committerKirill Bulatov <[email protected]>2020-12-08 13:05:09 +0000
commitbf24cb3e8db94a84fb4a24c407797ab6ff5ee109 (patch)
treeec3e2e0696147459460950ead2bc90591a6347ce /crates/ide_db
parentcbd3717f2c52b17aa9b15c2df4a364c62d17e4e1 (diff)
Tweak the search query params for better lookup speed
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/imports_locator.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs
index 31151ce24..b2980a5d6 100644
--- a/crates/ide_db/src/imports_locator.rs
+++ b/crates/ide_db/src/imports_locator.rs
@@ -34,6 +34,7 @@ pub fn find_exact_imports<'a>(
34pub fn find_similar_imports<'a>( 34pub fn find_similar_imports<'a>(
35 sema: &Semantics<'a, RootDatabase>, 35 sema: &Semantics<'a, RootDatabase>,
36 krate: Crate, 36 krate: Crate,
37 limit: Option<usize>,
37 name_to_import: &str, 38 name_to_import: &str,
38 ignore_modules: bool, 39 ignore_modules: bool,
39) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { 40) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
@@ -44,7 +45,14 @@ pub fn find_similar_imports<'a>(
44 external_query = external_query.exclude_import_kind(import_map::ImportKind::Module); 45 external_query = external_query.exclude_import_kind(import_map::ImportKind::Module);
45 } 46 }
46 47
47 find_imports(sema, krate, symbol_index::Query::new(name_to_import.to_string()), external_query) 48 let mut local_query = symbol_index::Query::new(name_to_import.to_string());
49
50 if let Some(limit) = limit {
51 local_query.limit(limit);
52 external_query = external_query.limit(limit);
53 }
54
55 find_imports(sema, krate, local_query, external_query)
48} 56}
49 57
50fn find_imports<'a>( 58fn find_imports<'a>(