diff options
author | Aleksey Kladov <[email protected]> | 2019-04-09 20:51:22 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-09 20:51:22 +0100 |
commit | 6b993a97602da5ddee4033d4d76a68471f8d1ee1 (patch) | |
tree | 7789a282bbdf26119e3a05370040c3e14bdadc1b /crates/ra_ide_api/src | |
parent | 2fc2d4373b2c4e96bebf320a84270eee3afe34aa (diff) |
migrate to salsas interning
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 9 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 7 |
2 files changed, 1 insertions, 15 deletions
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index ea4255d35..33d3903bb 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -20,7 +20,6 @@ use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; | |||
20 | #[derive(Debug)] | 20 | #[derive(Debug)] |
21 | pub(crate) struct RootDatabase { | 21 | pub(crate) struct RootDatabase { |
22 | runtime: salsa::Runtime<RootDatabase>, | 22 | runtime: salsa::Runtime<RootDatabase>, |
23 | interner: Arc<hir::HirInterner>, | ||
24 | pub(crate) last_gc: time::Instant, | 23 | pub(crate) last_gc: time::Instant, |
25 | pub(crate) last_gc_check: time::Instant, | 24 | pub(crate) last_gc_check: time::Instant, |
26 | } | 25 | } |
@@ -38,7 +37,6 @@ impl Default for RootDatabase { | |||
38 | fn default() -> RootDatabase { | 37 | fn default() -> RootDatabase { |
39 | let mut db = RootDatabase { | 38 | let mut db = RootDatabase { |
40 | runtime: salsa::Runtime::default(), | 39 | runtime: salsa::Runtime::default(), |
41 | interner: Default::default(), | ||
42 | last_gc: time::Instant::now(), | 40 | last_gc: time::Instant::now(), |
43 | last_gc_check: time::Instant::now(), | 41 | last_gc_check: time::Instant::now(), |
44 | }; | 42 | }; |
@@ -53,19 +51,12 @@ impl salsa::ParallelDatabase for RootDatabase { | |||
53 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { | 51 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { |
54 | salsa::Snapshot::new(RootDatabase { | 52 | salsa::Snapshot::new(RootDatabase { |
55 | runtime: self.runtime.snapshot(self), | 53 | runtime: self.runtime.snapshot(self), |
56 | interner: Arc::clone(&self.interner), | ||
57 | last_gc: self.last_gc.clone(), | 54 | last_gc: self.last_gc.clone(), |
58 | last_gc_check: self.last_gc_check.clone(), | 55 | last_gc_check: self.last_gc_check.clone(), |
59 | }) | 56 | }) |
60 | } | 57 | } |
61 | } | 58 | } |
62 | 59 | ||
63 | impl AsRef<hir::HirInterner> for RootDatabase { | ||
64 | fn as_ref(&self) -> &hir::HirInterner { | ||
65 | &self.interner | ||
66 | } | ||
67 | } | ||
68 | |||
69 | #[salsa::query_group(LineIndexDatabaseStorage)] | 60 | #[salsa::query_group(LineIndexDatabaseStorage)] |
70 | pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { | 61 | pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { |
71 | fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; | 62 | fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; |
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index e0fc1c123..d99a4e750 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -23,16 +23,11 @@ pub(crate) fn status(db: &RootDatabase) -> String { | |||
23 | let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); | 23 | let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); |
24 | let syntax_tree_stats = syntax_tree_stats(db); | 24 | let syntax_tree_stats = syntax_tree_stats(db); |
25 | let symbols_stats = db.query(LibrarySymbolsQuery).entries::<LibrarySymbolsStats>(); | 25 | let symbols_stats = db.query(LibrarySymbolsQuery).entries::<LibrarySymbolsStats>(); |
26 | let n_defs = { | ||
27 | let interner: &hir::HirInterner = db.as_ref(); | ||
28 | interner.len() | ||
29 | }; | ||
30 | format!( | 26 | format!( |
31 | "{}\n{}\n{}\n{} defs\n\nmemory:\n{}\ngc {:?} seconds ago", | 27 | "{}\n{}\n{}\n\n\nmemory:\n{}\ngc {:?} seconds ago", |
32 | files_stats, | 28 | files_stats, |
33 | symbols_stats, | 29 | symbols_stats, |
34 | syntax_tree_stats, | 30 | syntax_tree_stats, |
35 | n_defs, | ||
36 | MemoryStats::current(), | 31 | MemoryStats::current(), |
37 | db.last_gc.elapsed().as_secs(), | 32 | db.last_gc.elapsed().as_secs(), |
38 | ) | 33 | ) |