-
Notifications
You must be signed in to change notification settings - Fork 12
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
Construction from a Ptr{UInt8}
#8
Comments
yeah, this would be trivial to add; if someone wants to take a stab at it, we already have the InlineString constructor from |
The hard bit though is naming
|
Personally I'm fine just having this be another constructor and we can add big scary all-caps letters that it's unsafe if the Ptr is invalid. |
quinnj
added a commit
that referenced
this issue
Oct 19, 2021
Added docs around this new construction path. Added tests as well. The constructor from pointer just iteratively calls `addcodeunit` since it seems too much of a hassle to try and do our `unsafe_load` trick on the full `Ptr{InlineString}` and ensure the memory would be aligned and enough, etc. This path is much safer and should be pretty performant. Closed #8.
PR is up: #11 |
quinnj
added a commit
that referenced
this issue
Oct 19, 2021
* Allow construction of InlineStrings from pointer + optional length Added docs around this new construction path. Added tests as well. The constructor from pointer just iteratively calls `addcodeunit` since it seems too much of a hassle to try and do our `unsafe_load` trick on the full `Ptr{InlineString}` and ensure the memory would be aligned and enough, etc. This path is much safer and should be pretty performant. Closed #8. * fix tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Base provides
unsafe_string(::Ptr{UInt8}, num_bytes)::String
It would be nice to have a similar function for creating a
InlineString
that avoids ever allocating memory.The text was updated successfully, but these errors were encountered: