use salsa's LRU for syntax trees

This commit is contained in:
Aleksey Kladov 2019-06-07 09:50:32 +03:00
parent 80aa9d5f9f
commit fc2658b074
5 changed files with 11 additions and 7 deletions

View file

@ -7,7 +7,7 @@ use std::collections::HashSet;
use rustc_hash::FxHashMap;
use ra_db::{
CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa,
CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa::{self, Database},
};
use ra_hir::db;
use ra_project_model::ProjectWorkspace;
@ -43,6 +43,8 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
impl BatchDatabase {
pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase {
let mut db = BatchDatabase { runtime: salsa::Runtime::default() };
db.query_mut(ra_db::ParseQuery).set_lru_capacity(128);
db.query_mut(ra_hir::db::ParseMacroQuery).set_lru_capacity(128);
db.set_crate_graph(Arc::new(crate_graph));
// wait until Vfs has loaded all roots