Merge #649
649: remove dead code r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
55906341a6
@ -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 @@ fn init_crate(&mut self, db: &impl HirDatabase, crate_id: CrateId) {
|
||||
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<SourceItemId>,
|
||||
roots: &mut FxHashMap<FileId, ModuleId>,
|
||||
parent: Option<LinkId>,
|
||||
source: SourceItemId,
|
||||
) -> ModuleId {
|
||||
visited.insert(source);
|
||||
let id = self.alloc_mod(ModuleData {
|
||||
source,
|
||||
parent,
|
||||
@ -187,28 +179,21 @@ fn init_subtree(
|
||||
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::<Vec<_>>();
|
||||
(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)
|
||||
};
|
||||
|
||||
|
@ -94,17 +94,12 @@ fn from_iter<T>(iter: T) -> 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 @@ fn from_iter<T>(iter: T) -> LibrarySymbolsStats
|
||||
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
|
||||
}
|
||||
|
@ -137,12 +137,8 @@ pub(crate) fn len(&self) -> usize {
|
||||
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::<FileSymbol>()
|
||||
pub(crate) fn memory_size(&self) -> usize {
|
||||
self.map.as_fst().size() * self.symbols.len() * mem::size_of::<FileSymbol>()
|
||||
}
|
||||
|
||||
pub(crate) fn for_files(
|
||||
|
Loading…
Reference in New Issue
Block a user