Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOption<SmallVecN<T>> breaks the non-zero optimization #5
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This currently fails:
This is because
SmallVec<&u32>contains a[&u32; 4]field directly, and the compiler choses to use one of those&u32(which are non-zero) to set to zero to representNoneinOption<SmallVec<&u32>>. However,newinitializes the array withstd::mem::zeroed(), which conflicts with this optimization.https://github.com/bluss/arrayvec works around this by using
#[repr(u8)]on anenum. (The one used to makedropsound, see #4.)CC @pcwalton