mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
When possible, prefer NonNullableUnwrapped over NullableWrapped
e.g. in the scenario of `[ A Str, B, C, D ]`, rather than having one tag be nullable, we want to store the tag id in the pointer. This generally saves 8 bytes for every allocation, and prevents an allocations for all tags except A.
This commit is contained in:
parent
06dbe06971
commit
48fa4f7a8e
4 changed files with 72 additions and 74 deletions
|
@ -2327,32 +2327,6 @@ fn issue_4557() {
|
|||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn nullable_wrapped_with_non_nullable_singleton_tags() {
|
||||
indoc!(
|
||||
r###"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
F : [
|
||||
A F,
|
||||
B,
|
||||
C,
|
||||
]
|
||||
|
||||
g : F -> Str
|
||||
g = \f -> when f is
|
||||
A _ -> "A"
|
||||
B -> "B"
|
||||
C -> "C"
|
||||
|
||||
main =
|
||||
g (A (B))
|
||||
|> Str.concat (g B)
|
||||
|> Str.concat (g C)
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn nullable_wrapped_with_nullable_not_last_index() {
|
||||
indoc!(
|
||||
|
@ -3260,3 +3234,24 @@ fn capture_void_layout_task() {
|
|||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn non_nullable_unwrapped_instead_of_nullable_wrapped() {
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
Ast : [ A, B, C Str Ast ]
|
||||
|
||||
main : Str
|
||||
main =
|
||||
x : Ast
|
||||
x = A
|
||||
|
||||
when x is
|
||||
A -> "A"
|
||||
B -> "B"
|
||||
C _ _ -> "C"
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue