diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-29 13:15:07 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-29 13:15:07 +0000 |
commit | 343029fa9e52cf4aae7f17ed6e0e6b5b0175a172 (patch) | |
tree | 004195234e0409ddc54514a2e8b737ed8e16b74e /crates/completion | |
parent | ef1177c5b5a7ced9866025a51c10e4375e2a37fd (diff) | |
parent | 42c24ff25f391a1e3662ce226d510aedc9d1f0e4 (diff) |
Merge #7077
7077: Avoid a couple of allocations r=Veykril a=lnicola
r? @Veykril
TBH I'm not sure this is worth it, but the other `Query` was already taking a `String`.
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates/completion')
-rw-r--r-- | crates/completion/src/completions/unqualified_path.rs | 4 | ||||
-rw-r--r-- | crates/completion/src/lib.rs | 2 |
2 files changed, 3 insertions, 3 deletions
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<() | |||
135 | let anchor = ctx.name_ref_syntax.as_ref()?; | 135 | let anchor = ctx.name_ref_syntax.as_ref()?; |
136 | let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; | 136 | let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; |
137 | 137 | ||
138 | let user_input_lowercased = potential_import_name.to_lowercase(); | ||
138 | let mut all_mod_paths = imports_locator::find_similar_imports( | 139 | let mut all_mod_paths = imports_locator::find_similar_imports( |
139 | &ctx.sema, | 140 | &ctx.sema, |
140 | ctx.krate?, | 141 | ctx.krate?, |
141 | Some(40), | 142 | Some(40), |
142 | &potential_import_name, | 143 | potential_import_name, |
143 | true, | 144 | true, |
144 | ) | 145 | ) |
145 | .filter_map(|import_candidate| { | 146 | .filter_map(|import_candidate| { |
@@ -155,7 +156,6 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() | |||
155 | .filter(|(mod_path, _)| mod_path.len() > 1) | 156 | .filter(|(mod_path, _)| mod_path.len() > 1) |
156 | .collect::<Vec<_>>(); | 157 | .collect::<Vec<_>>(); |
157 | 158 | ||
158 | let user_input_lowercased = potential_import_name.to_lowercase(); | ||
159 | all_mod_paths.sort_by_cached_key(|(mod_path, _)| { | 159 | all_mod_paths.sort_by_cached_key(|(mod_path, _)| { |
160 | compute_fuzzy_completion_order_key(mod_path, &user_input_lowercased) | 160 | compute_fuzzy_completion_order_key(mod_path, &user_input_lowercased) |
161 | }); | 161 | }); |
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( | |||
137 | config: &CompletionConfig, | 137 | config: &CompletionConfig, |
138 | position: FilePosition, | 138 | position: FilePosition, |
139 | full_import_path: &str, | 139 | full_import_path: &str, |
140 | imported_name: &str, | 140 | imported_name: String, |
141 | ) -> Option<Vec<TextEdit>> { | 141 | ) -> Option<Vec<TextEdit>> { |
142 | let ctx = CompletionContext::new(db, position, config)?; | 142 | let ctx = CompletionContext::new(db, position, config)?; |
143 | let anchor = ctx.name_ref_syntax.as_ref()?; | 143 | let anchor = ctx.name_ref_syntax.as_ref()?; |