|
80 | 80 | function String(v::ReinterpretArray{UInt8, 1, S, Vector{S}, IsReshaped}) where {S, IsReshaped}
|
81 | 81 | len = length(v)
|
82 | 82 | len == 0 && return ""
|
83 |
| - ref = v.parent.ref |
84 |
| - if ref.ptr_or_offset == ref.mem.ptr |
85 |
| - str = ccall(:jl_genericmemory_to_string, Ref{String}, (Any, Int), ref.mem, len) |
86 |
| - else |
87 |
| - str = ccall(:jl_pchar_to_string, Ref{String}, (Ptr{S}, Int), ref, len) |
88 |
| - end |
89 |
| - # optimized empty!(v.parent); sizehint!(v.parent, 0) calls |
90 |
| - setfield!(v.parent, :size, (0,)) |
91 |
| - setfield!(v.parent, :ref, memoryref(Memory{S}())) |
92 |
| - return str |
| 83 | + return ccall(:jl_pchar_to_string, Ref{String}, (Ptr{S}, Int), v.parent.ref, len) |
| 84 | +end |
| 85 | +function String(v::ReinterpretArray{UInt8, 1, S, Memory{S}, IsReshaped}) where {S, IsReshaped} |
| 86 | + len = length(v) |
| 87 | + len == 0 && return "" |
| 88 | + return ccall(:jl_pchar_to_string, Ref{String}, (Ptr{S}, Int), v.parent.ptr, len) |
93 | 89 | end
|
94 | 90 |
|
95 | 91 | "Create a string re-using the memory, if possible.
|
|
0 commit comments