From 42c24ff25f391a1e3662ce226d510aedc9d1f0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 29 Dec 2020 14:35:49 +0200 Subject: Avoid a couple of allocations --- crates/completion/src/completions/unqualified_path.rs | 4 ++-- crates/completion/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/completion/src') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 59f950189..81a6d00e2 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -135,11 +135,12 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() let anchor = ctx.name_ref_syntax.as_ref()?; let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; + let user_input_lowercased = potential_import_name.to_lowercase(); let mut all_mod_paths = imports_locator::find_similar_imports( &ctx.sema, ctx.krate?, Some(40), - &potential_import_name, + potential_import_name, true, ) .filter_map(|import_candidate| { @@ -155,7 +156,6 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() .filter(|(mod_path, _)| mod_path.len() > 1) .collect::>(); - let user_input_lowercased = potential_import_name.to_lowercase(); all_mod_paths.sort_by_cached_key(|(mod_path, _)| { compute_fuzzy_completion_order_key(mod_path, &user_input_lowercased) }); diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index 8e27bb153..c57d05bbe 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs @@ -137,7 +137,7 @@ pub fn resolve_completion_edits( config: &CompletionConfig, position: FilePosition, full_import_path: &str, - imported_name: &str, + imported_name: String, ) -> Option> { let ctx = CompletionContext::new(db, position, config)?; let anchor = ctx.name_ref_syntax.as_ref()?; -- cgit v1.2.3