diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-12 11:36:47 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-12 11:36:47 +0100 |
commit | 03645c55761f8c9345ee3837a6010e65e7a80179 (patch) | |
tree | 9c24cb112429b0334762063e71a65a1907386e59 /crates/ra_ide_api/src | |
parent | 6296f51678843c96a4ab1f1e6784b6d69222e072 (diff) | |
parent | fed52706def9a9f5d33edc7dd9848a02ae475ba5 (diff) |
Merge #1382
1382: use salsa's LRU for syntax trees r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/change.rs | 1 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 11 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 11 |
3 files changed, 20 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index 247dc0fee..ce03a0f95 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs | |||
@@ -225,7 +225,6 @@ impl RootDatabase { | |||
225 | let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); | 225 | let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); |
226 | 226 | ||
227 | self.query(ra_db::ParseQuery).sweep(sweep); | 227 | self.query(ra_db::ParseQuery).sweep(sweep); |
228 | |||
229 | self.query(hir::db::ParseMacroQuery).sweep(sweep); | 228 | self.query(hir::db::ParseMacroQuery).sweep(sweep); |
230 | self.query(hir::db::MacroDefQuery).sweep(sweep); | 229 | self.query(hir::db::MacroDefQuery).sweep(sweep); |
231 | self.query(hir::db::MacroArgQuery).sweep(sweep); | 230 | self.query(hir::db::MacroArgQuery).sweep(sweep); |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index d1a452ecb..b3f395502 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -5,7 +5,7 @@ use std::{ | |||
5 | 5 | ||
6 | use ra_db::{ | 6 | use ra_db::{ |
7 | CheckCanceled, FileId, Canceled, SourceDatabase, | 7 | CheckCanceled, FileId, Canceled, SourceDatabase, |
8 | salsa, | 8 | salsa::{self, Database}, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; | 11 | use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; |
@@ -41,6 +41,12 @@ impl salsa::Database for RootDatabase { | |||
41 | 41 | ||
42 | impl Default for RootDatabase { | 42 | impl Default for RootDatabase { |
43 | fn default() -> RootDatabase { | 43 | fn default() -> RootDatabase { |
44 | RootDatabase::new(None) | ||
45 | } | ||
46 | } | ||
47 | |||
48 | impl RootDatabase { | ||
49 | pub fn new(lru_capacity: Option<usize>) -> RootDatabase { | ||
44 | let mut db = RootDatabase { | 50 | let mut db = RootDatabase { |
45 | runtime: salsa::Runtime::default(), | 51 | runtime: salsa::Runtime::default(), |
46 | last_gc: time::Instant::now(), | 52 | last_gc: time::Instant::now(), |
@@ -49,6 +55,9 @@ impl Default for RootDatabase { | |||
49 | db.set_crate_graph(Default::default()); | 55 | db.set_crate_graph(Default::default()); |
50 | db.set_local_roots(Default::default()); | 56 | db.set_local_roots(Default::default()); |
51 | db.set_library_roots(Default::default()); | 57 | db.set_library_roots(Default::default()); |
58 | let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP); | ||
59 | db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity); | ||
60 | db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity); | ||
52 | db | 61 | db |
53 | } | 62 | } |
54 | } | 63 | } |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index dbebf50a6..8741e736f 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -242,12 +242,21 @@ pub struct CallInfo { | |||
242 | } | 242 | } |
243 | 243 | ||
244 | /// `AnalysisHost` stores the current state of the world. | 244 | /// `AnalysisHost` stores the current state of the world. |
245 | #[derive(Debug, Default)] | 245 | #[derive(Debug)] |
246 | pub struct AnalysisHost { | 246 | pub struct AnalysisHost { |
247 | db: db::RootDatabase, | 247 | db: db::RootDatabase, |
248 | } | 248 | } |
249 | 249 | ||
250 | impl Default for AnalysisHost { | ||
251 | fn default() -> AnalysisHost { | ||
252 | AnalysisHost::new(None) | ||
253 | } | ||
254 | } | ||
255 | |||
250 | impl AnalysisHost { | 256 | impl AnalysisHost { |
257 | pub fn new(lru_capcity: Option<usize>) -> AnalysisHost { | ||
258 | AnalysisHost { db: db::RootDatabase::new(lru_capcity) } | ||
259 | } | ||
251 | /// Returns a snapshot of the current state, which you can query for | 260 | /// Returns a snapshot of the current state, which you can query for |
252 | /// semantic information. | 261 | /// semantic information. |
253 | pub fn analysis(&self) -> Analysis { | 262 | pub fn analysis(&self) -> Analysis { |