From e903f58d29662b5509fb20c74d7c4131271bfbf0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 21 Dec 2019 19:40:20 +0100 Subject: More profiling --- crates/ra_hir/src/from_source.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index ebd9ee2a8..6314be8d4 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -7,6 +7,7 @@ use hir_def::{ StaticId, StructId, TraitId, TypeAliasId, UnionId, VariantId, }; use hir_expand::{name::AsName, AstId, MacroDefId, MacroDefKind}; +use ra_db::FileId; use ra_prof::profile; use ra_syntax::{ ast::{self, AstNode, NameOwner}, @@ -206,10 +207,14 @@ impl Module { }; let original_file = src.file_id.original_file(db); + Module::from_file(db, original_file) + } - let (krate, local_id) = db.relevant_crates(original_file).iter().find_map(|&crate_id| { + fn from_file(db: &impl DefDatabase, file: FileId) -> Option { + let _p = profile("Module::from_file"); + let (krate, local_id) = db.relevant_crates(file).iter().find_map(|&crate_id| { let crate_def_map = db.crate_def_map(crate_id); - let local_id = crate_def_map.modules_for_file(original_file).next()?; + let local_id = crate_def_map.modules_for_file(file).next()?; Some((crate_id, local_id)) })?; Some(Module { id: ModuleId { krate, local_id } }) -- cgit v1.2.3