-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
draft: Optimize Option<CompactStr> to be the same size as CompactStr #22
Conversation
How attached are you to the Then I think you can extract the discriminant out of the union, and use a pub struct DiscriminantMask {
val: NonMaxU8,
}
pub struct Repr {
mask: DiscriminantMask,
inner: ReprInner,
}
pub union ReprInner {
heap: ManuallyDrop<HeapString>,
inline: InlineString,
} I think there will be some amount of refactoring (e.g. working with the size value of |
I'm pretty attached to the That being said, maybe we can use the layout you proposed and only transmute for the |
Update mayhem.yml
Completed in #105 |
This is a proof of concept to show that it's possible in stable Rust to get
std::mem::size_of<CompactStr> == std::mem::size_of::<Option<CompactStr>>()
.Unfortunately as-is the performance of
CompactStr
is degraded. We would need to fix this before merging.Fixes #19