Add a more efficient implementation for String(::ReinterpretArray) (#58438)
I added a new method `String(::ReinterpretArray{UInt8, 1, S, Vector{S},
IsReshaped})`, which is a copy of `String(::Vector{UInt8})` but using
`v.parent` instead of `v`. I'm not sure if the same can be done for more
generic `ReinterpretArray`s or for other `AbstractVector`s, I'd like
some input on that if possible.
Previous behavior:
```julia
function test()
a = reinterpret(UInt8, rand(UInt32, 2^27))
b = copy(a)
@time A = String(a) # 1.133837 seconds (2 allocations: 512.000 MiB, 0.06% gc time)
@time B = String(b) # 0.586990 seconds (1 allocation: 512.000 MiB)
A == B # true
end
```
New behavior:
```julia
function test()
a = reinterpret(UInt8, rand(UInt32, 2^27))
b = copy(a)
@time A = String(a) # 0.458837 seconds (1 allocation: 512.000 MiB)
@time B = String(b) # 0.475022 seconds (1 allocation: 512.000 MiB)
A == B # true
end
```
---------
Co-authored-by: Andy Dienes <51664769+adienes@users.noreply.github.com>
Co-authored-by: Andy Dienes <andydienes@gmail.com>