aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/item_tree.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index 5155b6111..31f3c4bd8 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -184,6 +184,7 @@ impl ItemTree {
184 if let Some(attrs) = top_attrs { 184 if let Some(attrs) = top_attrs {
185 item_tree.attrs.insert(AttrOwner::TopLevel, attrs); 185 item_tree.attrs.insert(AttrOwner::TopLevel, attrs);
186 } 186 }
187 item_tree.shrink_to_fit();
187 Arc::new(item_tree) 188 Arc::new(item_tree)
188 } 189 }
189 190
@@ -196,6 +197,51 @@ impl ItemTree {
196 } 197 }
197 } 198 }
198 199
200 fn shrink_to_fit(&mut self) {
201 if let Some(data) = &mut self.data {
202 let ItemTreeData {
203 imports,
204 extern_crates,
205 functions,
206 structs,
207 fields,
208 unions,
209 enums,
210 variants,
211 consts,
212 statics,
213 traits,
214 impls,
215 type_aliases,
216 mods,
217 macro_calls,
218 exprs,
219 vis,
220 generics,
221 } = &mut **data;
222
223 imports.shrink_to_fit();
224 extern_crates.shrink_to_fit();
225 functions.shrink_to_fit();
226 structs.shrink_to_fit();
227 fields.shrink_to_fit();
228 unions.shrink_to_fit();
229 enums.shrink_to_fit();
230 variants.shrink_to_fit();
231 consts.shrink_to_fit();
232 statics.shrink_to_fit();
233 traits.shrink_to_fit();
234 impls.shrink_to_fit();
235 type_aliases.shrink_to_fit();
236 mods.shrink_to_fit();
237 macro_calls.shrink_to_fit();
238 exprs.shrink_to_fit();
239
240 vis.arena.shrink_to_fit();
241 generics.arena.shrink_to_fit();
242 }
243 }
244
199 /// Returns an iterator over all items located at the top level of the `HirFileId` this 245 /// Returns an iterator over all items located at the top level of the `HirFileId` this
200 /// `ItemTree` was created from. 246 /// `ItemTree` was created from.
201 pub fn top_level_items(&self) -> &[ModItem] { 247 pub fn top_level_items(&self) -> &[ModItem] {