From 6cdfd1c3cf3d58eee90b5034d4e2d702fdc0f8f5 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 19 May 2020 00:39:50 +0200 Subject: Make `find_path_inner` a query This eliminates any remaining performance problems in the "Implement default members" assist (at least that I've found). --- crates/ra_hir_def/src/find_path.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_def/src/find_path.rs') 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::{ /// *from where* you're referring to the item, hence the `from` parameter. pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option { let _p = profile("find_path"); - find_path_inner(db, item, from, MAX_PATH_LEN) + db.find_path_inner(item, from, MAX_PATH_LEN) } const MAX_PATH_LEN: usize = 15; @@ -49,7 +49,7 @@ impl ModPath { } } -fn find_path_inner( +pub(crate) fn find_path_inner_query( db: &dyn DefDatabase, item: ItemInNs, from: ModuleId, @@ -140,8 +140,7 @@ fn find_path_inner( let mut best_path = None; let mut best_path_len = max_len; for (module_id, name) in importable_locations { - let mut path = match find_path_inner( - db, + let mut path = match db.find_path_inner( ItemInNs::Types(ModuleDefId::ModuleId(module_id)), from, best_path_len - 1, -- cgit v1.2.3