mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
Refactor NonRecursive to use flat_map and match
This commit is contained in:
parent
3ee957ca49
commit
ff48abdd06
1 changed files with 16 additions and 10 deletions
|
@ -932,20 +932,26 @@ impl<'a> Layout<'a> {
|
|||
|
||||
match variant {
|
||||
NonRecursive(tags) => {
|
||||
let tag_id_builtin = variant.tag_id_builtin();
|
||||
let max_alignment = tags
|
||||
.iter()
|
||||
.flat_map(|layouts| {
|
||||
layouts
|
||||
.iter()
|
||||
.map(|layout| layout.alignment_bytes(pointer_size))
|
||||
})
|
||||
.max();
|
||||
|
||||
match max_alignment {
|
||||
Some(align) => {
|
||||
let tag_id_builtin = variant.tag_id_builtin();
|
||||
|
||||
tags.iter()
|
||||
.map(|x| x.iter())
|
||||
.flatten()
|
||||
.map(|x| x.alignment_bytes(pointer_size))
|
||||
.max()
|
||||
.map(|w| {
|
||||
round_up_to_alignment(
|
||||
w,
|
||||
align,
|
||||
tag_id_builtin.alignment_bytes(pointer_size),
|
||||
)
|
||||
})
|
||||
.unwrap_or(0)
|
||||
}
|
||||
None => 0,
|
||||
}
|
||||
}
|
||||
Recursive(_)
|
||||
| NullableWrapped { .. }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue