Also use Rc for langtype::Type::Array

This is rarely used, but using Rc here like elsewhere allows us to
elide a few unneccessary memory allocations when copying such types.
The speed impact is not measurable though. With heaptrack I see that
we get rid of the last ~7600 allocations in my benchmark when cloning
Type.
This commit is contained in:
Milian Wolff 2024-10-25 22:18:18 +02:00 committed by Olivier Goffart
parent fd0eb01c55
commit 0abfb056a1
7 changed files with 14 additions and 11 deletions

View file

@ -1885,7 +1885,7 @@ pub fn type_from_node(
} else if let Some(object_node) = node.ObjectType() {
type_struct_from_node(object_node, diag, tr, None, None)
} else if let Some(array_node) = node.ArrayType() {
Type::Array(Box::new(type_from_node(array_node.Type(), diag, tr)))
Type::Array(Rc::new(type_from_node(array_node.Type(), diag, tr)))
} else {
assert!(diag.has_errors());
Type::Invalid