diff options
author | Aleksey Kladov <[email protected]> | 2019-05-22 09:31:07 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-05-22 09:31:07 +0100 |
commit | f15bb3c98a76dd801d49ccf19958edaa74048b63 (patch) | |
tree | f0980fb5386ace6e2008e8844878070662c8d5e9 /crates | |
parent | 67d5927b160aa5ec66fb6dae5d7075ebb509066f (diff) |
add profile calls to parsing/expansion routines
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_db/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 08aef9bf5..5328303d2 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml | |||
@@ -12,4 +12,5 @@ parking_lot = "0.7.0" | |||
12 | 12 | ||
13 | ra_arena = { path = "../ra_arena" } | 13 | ra_arena = { path = "../ra_arena" } |
14 | ra_syntax = { path = "../ra_syntax" } | 14 | ra_syntax = { path = "../ra_syntax" } |
15 | ra_prof = { path = "../ra_prof" } | ||
15 | test_utils = { path = "../test_utils" } | 16 | test_utils = { path = "../test_utils" } |
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index bf567721a..68b9a7143 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -6,6 +6,7 @@ use std::{panic, sync::Arc}; | |||
6 | 6 | ||
7 | use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; | 7 | use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; |
8 | use relative_path::RelativePathBuf; | 8 | use relative_path::RelativePathBuf; |
9 | use ra_prof::profile; | ||
9 | 10 | ||
10 | pub use ::salsa as salsa; | 11 | pub use ::salsa as salsa; |
11 | pub use crate::{ | 12 | pub use crate::{ |
@@ -72,6 +73,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug { | |||
72 | #[salsa::input] | 73 | #[salsa::input] |
73 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 74 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
74 | // Parses the file into the syntax tree. | 75 | // Parses the file into the syntax tree. |
76 | #[salsa::invoke(parse_query)] | ||
75 | fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>; | 77 | fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>; |
76 | /// Path to a file, relative to the root of its source root. | 78 | /// Path to a file, relative to the root of its source root. |
77 | #[salsa::input] | 79 | #[salsa::input] |
@@ -96,7 +98,8 @@ fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<Cra | |||
96 | Arc::new(res) | 98 | Arc::new(res) |
97 | } | 99 | } |
98 | 100 | ||
99 | fn parse(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> { | 101 | fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> { |
102 | let _p = profile("parse_query"); | ||
100 | let text = db.file_text(file_id); | 103 | let text = db.file_text(file_id); |
101 | SourceFile::parse(&*text) | 104 | SourceFile::parse(&*text) |
102 | } | 105 | } |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index f901a7432..2eb7f0da0 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -5,6 +5,7 @@ use std::{ | |||
5 | 5 | ||
6 | use ra_db::{FileId, salsa}; | 6 | use ra_db::{FileId, salsa}; |
7 | use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode}; | 7 | use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode}; |
8 | use ra_prof::profile; | ||
8 | use mbe::MacroRules; | 9 | use mbe::MacroRules; |
9 | 10 | ||
10 | use crate::{ | 11 | use crate::{ |
@@ -60,6 +61,7 @@ impl HirFileId { | |||
60 | db: &impl DefDatabase, | 61 | db: &impl DefDatabase, |
61 | file_id: HirFileId, | 62 | file_id: HirFileId, |
62 | ) -> Option<TreeArc<SyntaxNode>> { | 63 | ) -> Option<TreeArc<SyntaxNode>> { |
64 | let _p = profile("parse_or_expand_query"); | ||
63 | match file_id.0 { | 65 | match file_id.0 { |
64 | HirFileIdRepr::File(file_id) => Some(db.parse(file_id).syntax().to_owned()), | 66 | HirFileIdRepr::File(file_id) => Some(db.parse(file_id).syntax().to_owned()), |
65 | HirFileIdRepr::Macro(macro_file) => { | 67 | HirFileIdRepr::Macro(macro_file) => { |