mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
make LRU cache configurable
This commit is contained in:
parent
15668119de
commit
fed52706de
8 changed files with 48 additions and 11 deletions
|
@ -41,6 +41,12 @@ impl salsa::Database for RootDatabase {
|
|||
|
||||
impl Default for RootDatabase {
|
||||
fn default() -> RootDatabase {
|
||||
RootDatabase::new(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl RootDatabase {
|
||||
pub fn new(lru_capacity: Option<usize>) -> RootDatabase {
|
||||
let mut db = RootDatabase {
|
||||
runtime: salsa::Runtime::default(),
|
||||
last_gc: time::Instant::now(),
|
||||
|
@ -49,9 +55,9 @@ impl Default for RootDatabase {
|
|||
db.set_crate_graph(Default::default());
|
||||
db.set_local_roots(Default::default());
|
||||
db.set_library_roots(Default::default());
|
||||
let lru_cap = ra_db::DEFAULT_LRU_CAP;
|
||||
db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_cap);
|
||||
db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_cap);
|
||||
let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP);
|
||||
db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity);
|
||||
db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity);
|
||||
db
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,12 +242,21 @@ pub struct CallInfo {
|
|||
}
|
||||
|
||||
/// `AnalysisHost` stores the current state of the world.
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct AnalysisHost {
|
||||
db: db::RootDatabase,
|
||||
}
|
||||
|
||||
impl Default for AnalysisHost {
|
||||
fn default() -> AnalysisHost {
|
||||
AnalysisHost::new(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl AnalysisHost {
|
||||
pub fn new(lru_capcity: Option<usize>) -> AnalysisHost {
|
||||
AnalysisHost { db: db::RootDatabase::new(lru_capcity) }
|
||||
}
|
||||
/// Returns a snapshot of the current state, which you can query for
|
||||
/// semantic information.
|
||||
pub fn analysis(&self) -> Analysis {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue