-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]
Description
The docstring of String says:
To avoid truncation
of Vector{UInt8} data, use String(copy(v)); for other AbstractVector types,
String(v) already makes a copy.
Since Memory is an AbstractVector, String should make a copy. However, it doesn't look like this is happening in:
Lines 67 to 71 in 9d8e0e7
| function String(v::Memory{UInt8}) | |
| len = length(v) | |
| len == 0 && return "" | |
| return ccall(:jl_genericmemory_to_string, Ref{String}, (Any, Int), v, len) | |
| end |
julia> v = Memory{UInt8}(undef, 10);
julia> fill!(v, 0x01);
julia> String(v)
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
julia> v
0-element Memory{UInt8}Maybe the current String(v::Memory{UInt8}) method could be renamed to something like take_string! to make it clear that it can mutate v.
jakobnissennsajko
Metadata
Metadata
Assignees
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]