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/ide_db/src/imports_locator.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ide_db') 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; pub fn find_exact_imports<'a>( sema: &Semantics<'a, RootDatabase>, krate: Crate, - name_to_import: &str, + name_to_import: String, ) -> impl Iterator> { let _p = profile::span("find_exact_imports"); find_imports( sema, krate, { - let mut local_query = symbol_index::Query::new(name_to_import.to_string()); + let mut local_query = symbol_index::Query::new(name_to_import.clone()); local_query.exact(); local_query.limit(40); local_query @@ -39,18 +39,18 @@ pub fn find_similar_imports<'a>( sema: &Semantics<'a, RootDatabase>, krate: Crate, limit: Option, - fuzzy_search_string: &str, + fuzzy_search_string: String, name_only: bool, ) -> impl Iterator> { let _p = profile::span("find_similar_imports"); - let mut external_query = - import_map::Query::new(fuzzy_search_string).search_mode(import_map::SearchMode::Fuzzy); + let mut external_query = import_map::Query::new(fuzzy_search_string.clone()) + .search_mode(import_map::SearchMode::Fuzzy); if name_only { external_query = external_query.name_only(); } - let mut local_query = symbol_index::Query::new(fuzzy_search_string.to_string()); + let mut local_query = symbol_index::Query::new(fuzzy_search_string); if let Some(limit) = limit { local_query.limit(limit); -- cgit v1.2.3