From d4b135f38c8c0050768c50e62043ddca5f09079a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 21 Dec 2019 18:45:46 +0100 Subject: Optimize and profile --- crates/ra_hir/Cargo.toml | 1 + crates/ra_hir/src/from_source.rs | 4 ++++ crates/ra_hir/src/source_binder.rs | 3 +++ 3 files changed, 8 insertions(+) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 6ca9cc2e7..7dc31ad3c 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -14,6 +14,7 @@ either = "1.5" ra_syntax = { path = "../ra_syntax" } ra_db = { path = "../ra_db" } +ra_prof = { path = "../ra_prof" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 42ca55fe7..ebd9ee2a8 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_prof::profile; use ra_syntax::{ ast::{self, AstNode, NameOwner}, match_ast, SyntaxNode, @@ -169,6 +170,7 @@ impl TypeParam { impl Module { pub fn from_declaration(db: &impl DefDatabase, src: InFile) -> Option { + let _p = profile("Module::from_declaration"); let parent_declaration = src.value.syntax().ancestors().skip(1).find_map(ast::Module::cast); let parent_module = match parent_declaration { @@ -191,6 +193,7 @@ impl Module { } pub fn from_definition(db: &impl DefDatabase, src: InFile) -> Option { + let _p = profile("Module::from_definition"); match src.value { ModuleSource::Module(ref module) => { assert!(!module.has_semi()); @@ -214,6 +217,7 @@ impl Module { } fn analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> DynMap { + let _p = profile("analyze_container"); return child_by_source(db, src).unwrap_or_default(); fn child_by_source(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option { diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index b60a6b87e..85b378483 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -26,6 +26,7 @@ use hir_ty::{ method_resolution::{self, implements_trait}, Canonical, InEnvironment, InferenceResult, TraitEnvironment, Ty, }; +use ra_prof::profile; use ra_syntax::{ ast::{self, AstNode}, match_ast, AstPtr, @@ -83,6 +84,7 @@ fn def_with_body_from_child_node( db: &impl HirDatabase, child: InFile<&SyntaxNode>, ) -> Option { + let _p = profile("def_with_body_from_child_node"); child.cloned().ancestors_with_macros(db).find_map(|node| { let n = &node.value; match_ast! { @@ -169,6 +171,7 @@ impl SourceAnalyzer { node: InFile<&SyntaxNode>, offset: Option, ) -> SourceAnalyzer { + let _p = profile("SourceAnalyzer::new"); let def_with_body = def_with_body_from_child_node(db, node); if let Some(def) = def_with_body { let (_body, source_map) = db.body_with_source_map(def.into()); -- cgit v1.2.3