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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/completion/src/completions/unqualified_path.rs') 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) }); -- cgit v1.2.3