aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-06-24 15:14:58 +0100
committerJonas Schievink <[email protected]>2020-06-24 15:54:21 +0100
commitd4ddec2bdfc0766782a662b87e1456a9041e8182 (patch)
tree1e7e758e14b609fcec6aae19bd5001290286ec47 /crates/ra_hir_def/src
parent94169ee504bf1a5e59530c1ab1f5f5550ae45914 (diff)
Shrink arenas after building ItemTree
Diffstat (limited to 'crates/ra_hir_def/src')
-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] {