Merge #1363
1363: some work on memory r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
3573923279
4 changed files with 11 additions and 19 deletions
|
|
@ -74,6 +74,7 @@ pub trait DefDatabase: SourceDatabase {
|
|||
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
|
||||
|
||||
#[salsa::invoke(crate::source_id::AstIdMap::file_item_query)]
|
||||
#[salsa::transparent]
|
||||
fn ast_id_to_node(&self, file_id: HirFileId, ast_id: ErasedFileAstId) -> TreeArc<SyntaxNode>;
|
||||
|
||||
#[salsa::invoke(RawItems::raw_items_query)]
|
||||
|
|
@ -91,9 +92,6 @@ pub trait DefDatabase: SourceDatabase {
|
|||
#[salsa::invoke(crate::impl_block::impls_in_module)]
|
||||
fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>;
|
||||
|
||||
#[salsa::invoke(crate::impl_block::impls_in_module_source_map_query)]
|
||||
fn impls_in_module_source_map(&self, module: Module) -> Arc<ImplSourceMap>;
|
||||
|
||||
#[salsa::invoke(crate::impl_block::impls_in_module_with_source_map_query)]
|
||||
fn impls_in_module_with_source_map(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl ImplBlock {
|
|||
|
||||
/// Returns the syntax of the impl block
|
||||
pub fn source(&self, db: &impl DefDatabase) -> (HirFileId, TreeArc<ast::ImplBlock>) {
|
||||
let source_map = db.impls_in_module_source_map(self.module);
|
||||
let source_map = db.impls_in_module_with_source_map(self.module).1;
|
||||
let (file_id, source) = self.module.definition_source(db);
|
||||
(file_id, source_map.get(&source, self.impl_id))
|
||||
}
|
||||
|
|
@ -231,10 +231,3 @@ pub(crate) fn impls_in_module_with_source_map_query(
|
|||
pub(crate) fn impls_in_module(db: &impl DefDatabase, module: Module) -> Arc<ModuleImplBlocks> {
|
||||
db.impls_in_module_with_source_map(module).0
|
||||
}
|
||||
|
||||
pub(crate) fn impls_in_module_source_map_query(
|
||||
db: &impl DefDatabase,
|
||||
module: Module,
|
||||
) -> Arc<ImplSourceMap> {
|
||||
db.impls_in_module_with_source_map(module).1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,9 +228,9 @@ impl RootDatabase {
|
|||
|
||||
self.query(hir::db::ParseOrExpandQuery).sweep(sweep);
|
||||
self.query(hir::db::AstIdMapQuery).sweep(sweep);
|
||||
self.query(hir::db::AstIdToNodeQuery).sweep(sweep);
|
||||
|
||||
self.query(hir::db::RawItemsWithSourceMapQuery).sweep(sweep);
|
||||
self.query(hir::db::ImplsInModuleWithSourceMapQuery).sweep(sweep);
|
||||
self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use ra_syntax::{AstNode, Parse};
|
||||
use ra_syntax::{TreeArc, SyntaxNode};
|
||||
use ra_db::{
|
||||
ParseQuery, FileTextQuery, SourceRootId,
|
||||
FileTextQuery, SourceRootId,
|
||||
salsa::{Database, debug::{DebugQueryTable, TableEntry}},
|
||||
};
|
||||
use hir::HirFileId;
|
||||
|
||||
use crate::{
|
||||
FileId, db::RootDatabase,
|
||||
|
|
@ -16,7 +17,7 @@ use crate::{
|
|||
};
|
||||
|
||||
pub(crate) fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
|
||||
db.query(ParseQuery).entries::<SyntaxTreeStats>()
|
||||
db.query(hir::db::ParseOrExpandQuery).entries::<SyntaxTreeStats>()
|
||||
}
|
||||
|
||||
pub(crate) fn status(db: &RootDatabase) -> String {
|
||||
|
|
@ -72,17 +73,17 @@ impl fmt::Display for SyntaxTreeStats {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromIterator<TableEntry<FileId, Parse>> for SyntaxTreeStats {
|
||||
impl FromIterator<TableEntry<HirFileId, Option<TreeArc<SyntaxNode>>>> for SyntaxTreeStats {
|
||||
fn from_iter<T>(iter: T) -> SyntaxTreeStats
|
||||
where
|
||||
T: IntoIterator<Item = TableEntry<FileId, Parse>>,
|
||||
T: IntoIterator<Item = TableEntry<HirFileId, Option<TreeArc<SyntaxNode>>>>,
|
||||
{
|
||||
let mut res = SyntaxTreeStats::default();
|
||||
for entry in iter {
|
||||
res.total += 1;
|
||||
if let Some(value) = entry.value {
|
||||
if let Some(tree) = entry.value.and_then(|it| it) {
|
||||
res.retained += 1;
|
||||
res.retained_size += value.tree.syntax().memory_size_of_subtree();
|
||||
res.retained_size += tree.memory_size_of_subtree();
|
||||
}
|
||||
}
|
||||
res
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue