mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Optimize derived hash implementation for newtypes
When we have a newtype tag union, there is no reason to hash its discriminant.
This commit is contained in:
parent
2517695ce4
commit
a308ebb38c
3 changed files with 109 additions and 26 deletions
|
@ -1394,7 +1394,9 @@ mod hash {
|
|||
),
|
||||
TEST_HASHER,
|
||||
),
|
||||
RocList::from_slice(&[0, 0]),
|
||||
RocList::from_slice(&[
|
||||
// hash nothing because this is a newtype of a unit layout.
|
||||
] as &[u8]),
|
||||
RocList<u8>
|
||||
)
|
||||
}
|
||||
|
@ -1489,7 +1491,7 @@ mod hash {
|
|||
TEST_HASHER,
|
||||
),
|
||||
RocList::from_slice(&[
|
||||
0, 0, // A
|
||||
// discriminant is skipped because it's a newtype
|
||||
15, 23, 47
|
||||
]),
|
||||
RocList<u8>
|
||||
|
@ -1519,7 +1521,7 @@ mod hash {
|
|||
),
|
||||
RocList::from_slice(&[
|
||||
0, 0, // Ok
|
||||
0, 0, // A
|
||||
// A is skipped because it is a newtype
|
||||
15, 23, 47
|
||||
]),
|
||||
RocList<u8>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue