mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +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);
|
||||
let closure_type = Type::TagUnion(
|
||||
vec![(tag_name, tag_arguments)],
|
||||
Box::new(Type::Variable(closure_ext_var)),
|
||||
);
|
||||
// pick a more efficient representation if we don't actually capture anything
|
||||
let closure_type = if tag_arguments.is_empty() {
|
||||
Type::ClosureTag {
|
||||
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(
|
||||
Type::Variable(closure_var),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue