diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/module_tree.rs | 25 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 8 |
3 files changed, 10 insertions, 35 deletions
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 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use rustc_hash::{FxHashMap, FxHashSet}; | ||
4 | use arrayvec::ArrayVec; | 3 | use arrayvec::ArrayVec; |
5 | use relative_path::RelativePathBuf; | 4 | use relative_path::RelativePathBuf; |
6 | use ra_db::{FileId, SourceRoot, CrateId}; | 5 | use ra_db::{FileId, SourceRoot, CrateId}; |
@@ -147,28 +146,21 @@ impl ModuleTree { | |||
147 | let file_id = crate_graph.crate_root(crate_id); | 146 | let file_id = crate_graph.crate_root(crate_id); |
148 | let source_root_id = db.file_source_root(file_id); | 147 | let source_root_id = db.file_source_root(file_id); |
149 | 148 | ||
150 | let mut roots = FxHashMap::default(); | ||
151 | let mut visited = FxHashSet::default(); | ||
152 | |||
153 | let source_root = db.source_root(source_root_id); | 149 | let source_root = db.source_root(source_root_id); |
154 | let source = SourceItemId { | 150 | let source = SourceItemId { |
155 | file_id: file_id.into(), | 151 | file_id: file_id.into(), |
156 | item_id: None, | 152 | item_id: None, |
157 | }; | 153 | }; |
158 | let module_id = self.init_subtree(db, &source_root, &mut visited, &mut roots, None, source); | 154 | self.init_subtree(db, &source_root, None, source); |
159 | roots.insert(file_id, module_id); | ||
160 | } | 155 | } |
161 | 156 | ||
162 | fn init_subtree( | 157 | fn init_subtree( |
163 | &mut self, | 158 | &mut self, |
164 | db: &impl HirDatabase, | 159 | db: &impl HirDatabase, |
165 | source_root: &SourceRoot, | 160 | source_root: &SourceRoot, |
166 | visited: &mut FxHashSet<SourceItemId>, | ||
167 | roots: &mut FxHashMap<FileId, ModuleId>, | ||
168 | parent: Option<LinkId>, | 161 | parent: Option<LinkId>, |
169 | source: SourceItemId, | 162 | source: SourceItemId, |
170 | ) -> ModuleId { | 163 | ) -> ModuleId { |
171 | visited.insert(source); | ||
172 | let id = self.alloc_mod(ModuleData { | 164 | let id = self.alloc_mod(ModuleData { |
173 | source, | 165 | source, |
174 | parent, | 166 | parent, |
@@ -187,28 +179,21 @@ impl ModuleTree { | |||
187 | let (points_to, problem) = resolve_submodule(db, source.file_id, &sub.name); | 179 | let (points_to, problem) = resolve_submodule(db, source.file_id, &sub.name); |
188 | let points_to = points_to | 180 | let points_to = points_to |
189 | .into_iter() | 181 | .into_iter() |
190 | .map(|file_id| match roots.remove(&file_id) { | 182 | .map(|file_id| { |
191 | Some(module_id) => { | 183 | self.init_subtree( |
192 | self.mods[module_id].parent = Some(link); | ||
193 | module_id | ||
194 | } | ||
195 | None => self.init_subtree( | ||
196 | db, | 184 | db, |
197 | source_root, | 185 | source_root, |
198 | visited, | ||
199 | roots, | ||
200 | Some(link), | 186 | Some(link), |
201 | SourceItemId { | 187 | SourceItemId { |
202 | file_id: file_id.into(), | 188 | file_id: file_id.into(), |
203 | item_id: None, | 189 | item_id: None, |
204 | }, | 190 | }, |
205 | ), | 191 | ) |
206 | }) | 192 | }) |
207 | .collect::<Vec<_>>(); | 193 | .collect::<Vec<_>>(); |
208 | (points_to, problem) | 194 | (points_to, problem) |
209 | } else { | 195 | } else { |
210 | let points_to = | 196 | let points_to = self.init_subtree(db, source_root, Some(link), sub.source); |
211 | self.init_subtree(db, source_root, visited, roots, Some(link), sub.source); | ||
212 | (vec![points_to], None) | 197 | (vec![points_to], None) |
213 | }; | 198 | }; |
214 | 199 | ||
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<TableEntry<FileId, TreeArc<SourceFile>>> for SyntaxTreeStats { | |||
94 | #[derive(Default)] | 94 | #[derive(Default)] |
95 | struct LibrarySymbolsStats { | 95 | struct LibrarySymbolsStats { |
96 | total: usize, | 96 | total: usize, |
97 | fst_size: Bytes, | 97 | size: Bytes, |
98 | symbols_size: Bytes, | ||
99 | } | 98 | } |
100 | 99 | ||
101 | impl fmt::Display for LibrarySymbolsStats { | 100 | impl fmt::Display for LibrarySymbolsStats { |
102 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | 101 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
103 | write!( | 102 | write!(fmt, "{} ({}) symbols", self.total, self.size,) |
104 | fmt, | ||
105 | "{} ({} + {}) symbols", | ||
106 | self.total, self.fst_size, self.symbols_size | ||
107 | ) | ||
108 | } | 103 | } |
109 | } | 104 | } |
110 | 105 | ||
@@ -117,8 +112,7 @@ impl FromIterator<TableEntry<SourceRootId, Arc<SymbolIndex>>> for LibrarySymbols | |||
117 | for entry in iter { | 112 | for entry in iter { |
118 | let value = entry.value.unwrap(); | 113 | let value = entry.value.unwrap(); |
119 | res.total += value.len(); | 114 | res.total += value.len(); |
120 | res.fst_size += value.fst_size(); | 115 | res.size += value.memory_size(); |
121 | res.symbols_size += value.symbols_size(); | ||
122 | } | 116 | } |
123 | res | 117 | res |
124 | } | 118 | } |
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 { | |||
137 | self.symbols.len() | 137 | self.symbols.len() |
138 | } | 138 | } |
139 | 139 | ||
140 | pub(crate) fn fst_size(&self) -> usize { | 140 | pub(crate) fn memory_size(&self) -> usize { |
141 | self.map.as_fst().size() | 141 | self.map.as_fst().size() * self.symbols.len() * mem::size_of::<FileSymbol>() |
142 | } | ||
143 | |||
144 | pub(crate) fn symbols_size(&self) -> usize { | ||
145 | self.symbols.len() * mem::size_of::<FileSymbol>() | ||
146 | } | 142 | } |
147 | 143 | ||
148 | pub(crate) fn for_files( | 144 | pub(crate) fn for_files( |