Tweak the search query params for better lookup speed

This commit is contained in:
Kirill Bulatov 2020-12-08 14:38:43 +02:00
parent cbd3717f2c
commit bf24cb3e8d
2 changed files with 38 additions and 32 deletions

View file

@ -34,6 +34,7 @@ pub fn find_exact_imports<'a>(
pub fn find_similar_imports<'a>(
sema: &Semantics<'a, RootDatabase>,
krate: Crate,
limit: Option<usize>,
name_to_import: &str,
ignore_modules: bool,
) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
@ -44,7 +45,14 @@ pub fn find_similar_imports<'a>(
external_query = external_query.exclude_import_kind(import_map::ImportKind::Module);
}
find_imports(sema, krate, symbol_index::Query::new(name_to_import.to_string()), external_query)
let mut local_query = symbol_index::Query::new(name_to_import.to_string());
if let Some(limit) = limit {
local_query.limit(limit);
external_query = external_query.limit(limit);
}
find_imports(sema, krate, local_query, external_query)
}
fn find_imports<'a>(