Conversation
|
|
|
What about |
|
I like the idea of overloading |
|
Can't it just be string(buf) where buf::IOBuffer? |
No, |
|
There is repr for that. |
|
No that's yet another more verbose representation of the object. http://docs.julialang.org/en/release-0.5/stdlib/strings/?highlight=repr |
|
It could be I've just re-discovered that there was an issue for this naming debate, but not with many proposals: #8575. |
|
@ararslan as far as I can see only |
|
@dhoegh Oh you're right—I mistakenly thought |
|
+1 for |
|
So is the general preference for Something that escapes me is why the docs say "Obtain the contents of an IOBuffer as an array, without copying". Looking at the code, it seems to me that a copy is always made, even when it could be avoided by reusing the |
|
If it is seekable, writable, and backed by an Array{UInt8}, then it is no-copy. I agree that the seekable condition seems somewhat extraneous. |
|
Thanks, I hadn't noticed that the newly allocated array was of length 0 in the best case. I've updated the PR to use |
|
Should we merge now? |
67f45ff to
b0b8445
Compare
|
I'll merge tomorrow barring further suggestions or objections. |
d263b7f to
f1749ea
Compare
takebuf_string(b) is now simply String(take!(b)). Also remove
jl_takebuf_string, which did the same conversion from array to string in C,
and rename {jl,ios}_takebuf_array() to {jl,ios}_take_buffer().
f1749ea to
4b81b0c
Compare
|
Phew! It was hard to get into a mergeable state, |
|
This deprecation warning is sometimes wrong (and results in an error in those cases). When |
|
In which version did passing a |
|
At least the |
This implements one of the Stringapalooza tasks scheduled for 0.6 (#16107 and #16058 (comment)):
takebuf_arrayis now simplytakebuf, andtakebuf_string(b)is nowString(takebuf(b)).Points to discuss:
jl_takebuf_stringC function, which was used forIOStreammethod and performed the conversion from array to string in C. I don't think it should be a performance issue, but could someone confirm that?takebuf, but maybe another one is appropriate now? Could it be a method of a more generic function likecollectorArray?String(b::AbstractIOBuffer)method with a similar behavior, but it only works on seekable streams. One difference is that it doesn't callunmark, maybe there are others. Probably doesn't affect this PR, but I thought I would mention it.Fixes #8575.