mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
optimize non-capturing closure type
This commit is contained in:
parent
7c2e8cd812
commit
3139e73cf9
1 changed files with 13 additions and 5 deletions
|
@ -1415,11 +1415,19 @@ fn constrain_closure_size(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let tag_name = TagName::Closure(name);
|
// pick a more efficient representation if we don't actually capture anything
|
||||||
let closure_type = Type::TagUnion(
|
let closure_type = if tag_arguments.is_empty() {
|
||||||
vec![(tag_name, tag_arguments)],
|
Type::ClosureTag {
|
||||||
Box::new(Type::Variable(closure_ext_var)),
|
name,
|
||||||
);
|
ext: closure_ext_var,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let tag_name = TagName::Closure(name);
|
||||||
|
Type::TagUnion(
|
||||||
|
vec![(tag_name, tag_arguments)],
|
||||||
|
Box::new(Type::Variable(closure_ext_var)),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let finalizer = Eq(
|
let finalizer = Eq(
|
||||||
Type::Variable(closure_var),
|
Type::Variable(closure_var),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue