-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add takestring! and make String(::Memory)
not truncate#54372
base: master
Are you sure you want to change the base?
Conversation
Also, check for uses of julia/stdlib/FileWatching/src/pidfile.jl Lines 283 to 288 in f3561ae
#53962 |
The name makes me think that |
I would be in favor of that. Every time I have used an IOBuffer I have had to go to the docs to figure out how to get the data out of it correctly. |
So what's the specification of |
It does not truncate - except when the argument is a |
Do we need an underscore here? |
Triage had a long talk about this, #54369, #54156 and #54273. The conclusions we came to are
|
The style guide says not to use underscores "when readable" without, which I think applies here. |
String(::Memory)
not truncateString(::Memory)
not truncate
Can this be refined to "mutating an Array after its alias has been turned into a String is UB"? edit: For the record , I don't think it's right for us to put this contract on an API that's not marked |
Yes. observing it is not great but not UB. the only UB is if you mutate it. |
|
After triage, this PR now contains the following changes:
|
This commit builds upon JuliaLang#54438, re-using the old String(::Vector{UInt8}) impl, which now no longer truncates. Also remove takestring!(::Memory) - that function probably should not be defined
Co-authored-by: Steven G. Johnson <stevenj@mit.edu>
And use it unstead of takestring!(::Memory)
Rebased. Test failures look unrelated, but it's suspicious that they now failed twice on Windows. |
This function creates a string from a byte vector, truncating the vector and reusing its memory where possible.
This also removes the truncating behaviour of
String(::Memory)
- see #54369Still needs to be done
take_string!(::Memory)
should be used instead ofString(::Memory)
for efficiency [edit: couldn't find any]Closes #54369