diff options
author | Aleksey Kladov <[email protected]> | 2019-06-07 18:49:29 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-06-12 11:36:24 +0100 |
commit | fed52706def9a9f5d33edc7dd9848a02ae475ba5 (patch) | |
tree | be508002355e87b97bd98a64f1678f431ed4b3ae /crates/ra_ide_api/src | |
parent | 15668119de40b97011a1f2e2d065d11f25a5833a (diff) |
make LRU cache configurable
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 11 |
2 files changed, 19 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index cccf0ada4..b3f395502 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -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,9 +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()); |
52 | let lru_cap = ra_db::DEFAULT_LRU_CAP; | 58 | let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP); |
53 | db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_cap); | 59 | db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity); |
54 | db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_cap); | 60 | db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity); |
55 | db | 61 | db |
56 | } | 62 | } |
57 | } | 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 { |