don't pass closure argument if not expected

This commit is contained in:
Folkert 2021-09-17 22:51:51 +02:00
parent c68689a52b
commit 7416cc4e81
3 changed files with 52 additions and 3 deletions

View file

@ -455,6 +455,17 @@ impl<'a> LambdaSet<'a> {
}
}
pub fn member_does_not_need_closure_argument(&self, function_symbol: Symbol) -> bool {
match self.layout_for_member(function_symbol) {
ClosureRepresentation::Union {
alphabetic_order_fields,
..
} => alphabetic_order_fields.is_empty(),
ClosureRepresentation::AlphabeticOrderStruct(fields) => fields.is_empty(),
ClosureRepresentation::Other(_) => false,
}
}
pub fn layout_for_member(&self, function_symbol: Symbol) -> ClosureRepresentation<'a> {
debug_assert!(
self.set.iter().any(|(s, _)| *s == function_symbol),