Conversation
Author
|
I also just took the liberty of solving #33 by using |
Author
|
I'll also note that this PR now uses 2 bits for the expanded discriminant, but only 3 states ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #47.
As far as I can tell, there was no real need to use
MaybeUninit<InlineString>instead of justInlineStringdirectly, due to it being a POD type. All that was required was changing the types of pointer casts we do to directly use&self.data as *const _rather thanself.data.as_ptr()in various places.Due to no longer using the
MaybeUninitunion type, we are able to getOptionsize optimization out of theInlineString. To do this, I changedMarker(u8)toMarker(NonZeroU8)and changed it to use the low 2 bits for storing both the discriminant (as it already did), and also a non-zero bit to guarantee the requirement ofNonZeroU8. I've also changed the allocator alignment requirement to 4 instead of 2 to guarantee these bits are free to use; this should not cause issues on 32 or 64 bit systems, which are our targets.To ensure that a
BoxedStringwrite over the memory of theInlineStringdoes not violate the requirements ofNonZeroU8(and/or produce aNonevalue), theptrfield inBoxedStringwas changed to a newTaggedPtrtype that automatically handles setting the low 2 bits appropriately (and removing them when queried).I feel that additional testing should be done, but it currently passes all existing test cases and a few that I added specifically about size requirements and
SomevsNonechecks for small and large strings.