-
Notifications
You must be signed in to change notification settings - Fork 315
Description
In #2295 the ValType enum is going to be inflated from 4 bytes to 8 bytes due to the new representation of RefType. Previously RefType was [u8; 3] and in that PR it's changing to u32. There's some benchmarks and discussion of this at #2295 (comment). The tl;dr; is that the idea of having ValType and ValTypePacked is not going to work because it inevitably leads to runtime conversions between the two which is slower than just having one.
I wanted to open this though to at least record this as an issue. I don't believe that in Rust today the tradeoff of losing match-exhaustiveness is worth it. Perhaps in the future this may change (e.g. the speedups are worth it) or maybe some future Rust feature comes along (e.g. pattern types) which enables using enum and also having a 4-byte ValType. In the meantime though I think 8-byte ValType is the best we can do.