From 8ebb8d29e18d7cb18bd2b57b004dcecd65a96232 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 24 May 2021 15:13:23 +0200 Subject: internal: intern `TypeBound`s Doesn't save much memory (~2 mb), but interning things is generally a good pattern to follow --- crates/hir_def/src/item_tree/lower.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/hir_def/src/item_tree/lower.rs') diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 91cf75371..1a0e54413 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -384,7 +384,7 @@ impl<'a> Ctx<'a> { let ret_type = if func.async_token().is_some() { let future_impl = desugar_future_path(ret_type); - let ty_bound = TypeBound::Path(future_impl); + let ty_bound = Interned::new(TypeBound::Path(future_impl)); TypeRef::ImplTrait(vec![ty_bound]) } else { ret_type @@ -738,11 +738,12 @@ impl<'a> Ctx<'a> { Interned::new(generics) } - fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec { + fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec> { match node.type_bound_list() { - Some(bound_list) => { - bound_list.bounds().map(|it| TypeBound::from_ast(&self.body_ctx, it)).collect() - } + Some(bound_list) => bound_list + .bounds() + .map(|it| Interned::new(TypeBound::from_ast(&self.body_ctx, it))) + .collect(), None => Vec::new(), } } -- cgit v1.2.3 From 533e9207d39c27dc22de2645fc65891189a71739 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 24 May 2021 15:35:46 +0200 Subject: Intern `GenericArgs` This shaves off another ~4 mb or so --- crates/hir_def/src/item_tree/lower.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/hir_def/src/item_tree/lower.rs') diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 1a0e54413..b4389371f 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -811,7 +811,7 @@ fn desugar_future_path(orig: TypeRef) -> Path { let binding = AssociatedTypeBinding { name: name![Output], type_ref: Some(orig), bounds: Vec::new() }; last.bindings.push(binding); - generic_args.push(Some(Arc::new(last))); + generic_args.push(Some(Interned::new(last))); Path::from_known_path(path, generic_args) } -- cgit v1.2.3