mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
migrate to salsas interning
This commit is contained in:
parent
2fc2d4373b
commit
6b993a9760
8 changed files with 109 additions and 111 deletions
|
@ -20,7 +20,6 @@ use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}};
|
|||
#[derive(Debug)]
|
||||
pub(crate) struct RootDatabase {
|
||||
runtime: salsa::Runtime<RootDatabase>,
|
||||
interner: Arc<hir::HirInterner>,
|
||||
pub(crate) last_gc: time::Instant,
|
||||
pub(crate) last_gc_check: time::Instant,
|
||||
}
|
||||
|
@ -38,7 +37,6 @@ impl Default for RootDatabase {
|
|||
fn default() -> RootDatabase {
|
||||
let mut db = RootDatabase {
|
||||
runtime: salsa::Runtime::default(),
|
||||
interner: Default::default(),
|
||||
last_gc: time::Instant::now(),
|
||||
last_gc_check: time::Instant::now(),
|
||||
};
|
||||
|
@ -53,19 +51,12 @@ impl salsa::ParallelDatabase for RootDatabase {
|
|||
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
|
||||
salsa::Snapshot::new(RootDatabase {
|
||||
runtime: self.runtime.snapshot(self),
|
||||
interner: Arc::clone(&self.interner),
|
||||
last_gc: self.last_gc.clone(),
|
||||
last_gc_check: self.last_gc_check.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<hir::HirInterner> for RootDatabase {
|
||||
fn as_ref(&self) -> &hir::HirInterner {
|
||||
&self.interner
|
||||
}
|
||||
}
|
||||
|
||||
#[salsa::query_group(LineIndexDatabaseStorage)]
|
||||
pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled {
|
||||
fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
|
||||
|
|
|
@ -23,16 +23,11 @@ pub(crate) fn status(db: &RootDatabase) -> String {
|
|||
let files_stats = db.query(FileTextQuery).entries::<FilesStats>();
|
||||
let syntax_tree_stats = syntax_tree_stats(db);
|
||||
let symbols_stats = db.query(LibrarySymbolsQuery).entries::<LibrarySymbolsStats>();
|
||||
let n_defs = {
|
||||
let interner: &hir::HirInterner = db.as_ref();
|
||||
interner.len()
|
||||
};
|
||||
format!(
|
||||
"{}\n{}\n{}\n{} defs\n\nmemory:\n{}\ngc {:?} seconds ago",
|
||||
"{}\n{}\n{}\n\n\nmemory:\n{}\ngc {:?} seconds ago",
|
||||
files_stats,
|
||||
symbols_stats,
|
||||
syntax_tree_stats,
|
||||
n_defs,
|
||||
MemoryStats::current(),
|
||||
db.last_gc.elapsed().as_secs(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue