aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/find_path.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-21 00:48:02 +0100
committerGitHub <[email protected]>2020-05-21 00:48:02 +0100
commit42dd0ce51ffee1dbfc58be7ebb0861aa2331b9cc (patch)
tree6e436f2bb3f7d1088db31ce8d9aad0146ef9eec4 /crates/ra_hir_def/src/find_path.rs
parente632d07015e3aad6f81a87c5abf178ae60c86d1a (diff)
parent6cdfd1c3cf3d58eee90b5034d4e2d702fdc0f8f5 (diff)
Merge #4506
4506: Make `find_path_inner` a query r=matklad a=jonas-schievink This eliminates the remaining performance problems in the "Implement default members" assist (at least those that I've found). Closes https://github.com/rust-analyzer/rust-analyzer/issues/4498 Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/find_path.rs')
-rw-r--r--crates/ra_hir_def/src/find_path.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs
index 68d3cde08..4db798473 100644
--- a/crates/ra_hir_def/src/find_path.rs
+++ b/crates/ra_hir_def/src/find_path.rs
@@ -20,7 +20,7 @@ use crate::{
20/// *from where* you're referring to the item, hence the `from` parameter. 20/// *from where* you're referring to the item, hence the `from` parameter.
21pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> { 21pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> {
22 let _p = profile("find_path"); 22 let _p = profile("find_path");
23 find_path_inner(db, item, from, MAX_PATH_LEN) 23 db.find_path_inner(item, from, MAX_PATH_LEN)
24} 24}
25 25
26const MAX_PATH_LEN: usize = 15; 26const MAX_PATH_LEN: usize = 15;
@@ -49,7 +49,7 @@ impl ModPath {
49 } 49 }
50} 50}
51 51
52fn find_path_inner( 52pub(crate) fn find_path_inner_query(
53 db: &dyn DefDatabase, 53 db: &dyn DefDatabase,
54 item: ItemInNs, 54 item: ItemInNs,
55 from: ModuleId, 55 from: ModuleId,
@@ -140,8 +140,7 @@ fn find_path_inner(
140 let mut best_path = None; 140 let mut best_path = None;
141 let mut best_path_len = max_len; 141 let mut best_path_len = max_len;
142 for (module_id, name) in importable_locations { 142 for (module_id, name) in importable_locations {
143 let mut path = match find_path_inner( 143 let mut path = match db.find_path_inner(
144 db,
145 ItemInNs::Types(ModuleDefId::ModuleId(module_id)), 144 ItemInNs::Types(ModuleDefId::ModuleId(module_id)),
146 from, 145 from,
147 best_path_len - 1, 146 best_path_len - 1,