From 50a7598773eaa57379d81c3d917ab4c84d867a51 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 21:10:28 +0300 Subject: print one size for symbols --- crates/ra_ide_api/src/status.rs | 12 +++--------- crates/ra_ide_api/src/symbol_index.rs | 8 ++------ 2 files changed, 5 insertions(+), 15 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index 717537fcd..59159df98 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs @@ -94,17 +94,12 @@ impl FromIterator>> for SyntaxTreeStats { #[derive(Default)] struct LibrarySymbolsStats { total: usize, - fst_size: Bytes, - symbols_size: Bytes, + size: Bytes, } impl fmt::Display for LibrarySymbolsStats { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!( - fmt, - "{} ({} + {}) symbols", - self.total, self.fst_size, self.symbols_size - ) + write!(fmt, "{} ({}) symbols", self.total, self.size,) } } @@ -117,8 +112,7 @@ impl FromIterator>> for LibrarySymbols for entry in iter { let value = entry.value.unwrap(); res.total += value.len(); - res.fst_size += value.fst_size(); - res.symbols_size += value.symbols_size(); + res.size += value.memory_size(); } res } diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 69a669b8d..6baeabde6 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -137,12 +137,8 @@ impl SymbolIndex { self.symbols.len() } - pub(crate) fn fst_size(&self) -> usize { - self.map.as_fst().size() - } - - pub(crate) fn symbols_size(&self) -> usize { - self.symbols.len() * mem::size_of::() + pub(crate) fn memory_size(&self) -> usize { + self.map.as_fst().size() * self.symbols.len() * mem::size_of::() } pub(crate) fn for_files( -- cgit v1.2.3 From f0c6a040bd5f739de8462a1bec523181bad63d56 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 21:14:41 +0300 Subject: remove dead code --- crates/ra_hir/src/module_tree.rs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs index c00834c4c..d5ad9decb 100644 --- a/crates/ra_hir/src/module_tree.rs +++ b/crates/ra_hir/src/module_tree.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use rustc_hash::{FxHashMap, FxHashSet}; use arrayvec::ArrayVec; use relative_path::RelativePathBuf; use ra_db::{FileId, SourceRoot, CrateId}; @@ -147,28 +146,21 @@ impl ModuleTree { let file_id = crate_graph.crate_root(crate_id); let source_root_id = db.file_source_root(file_id); - let mut roots = FxHashMap::default(); - let mut visited = FxHashSet::default(); - let source_root = db.source_root(source_root_id); let source = SourceItemId { file_id: file_id.into(), item_id: None, }; - let module_id = self.init_subtree(db, &source_root, &mut visited, &mut roots, None, source); - roots.insert(file_id, module_id); + self.init_subtree(db, &source_root, None, source); } fn init_subtree( &mut self, db: &impl HirDatabase, source_root: &SourceRoot, - visited: &mut FxHashSet, - roots: &mut FxHashMap, parent: Option, source: SourceItemId, ) -> ModuleId { - visited.insert(source); let id = self.alloc_mod(ModuleData { source, parent, @@ -187,28 +179,21 @@ impl ModuleTree { let (points_to, problem) = resolve_submodule(db, source.file_id, &sub.name); let points_to = points_to .into_iter() - .map(|file_id| match roots.remove(&file_id) { - Some(module_id) => { - self.mods[module_id].parent = Some(link); - module_id - } - None => self.init_subtree( + .map(|file_id| { + self.init_subtree( db, source_root, - visited, - roots, Some(link), SourceItemId { file_id: file_id.into(), item_id: None, }, - ), + ) }) .collect::>(); (points_to, problem) } else { - let points_to = - self.init_subtree(db, source_root, visited, roots, Some(link), sub.source); + let points_to = self.init_subtree(db, source_root, Some(link), sub.source); (vec![points_to], None) }; -- cgit v1.2.3