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:
Folkert 2023-07-16 18:57:09 +02:00
parent 06dbe06971
commit 48fa4f7a8e
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 72 additions and 74 deletions

View file

@ -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"
"#
)
}