Revert "strings: fast path for `String` conversion of dense StringVie… #63740
I would rather have something analogous to #63375 for the time being, which at least keeps the fast path for Union{Vector{UInt8}, Memory{UInt8}} and subarrays thereof (with a TODO comment to revise in the future if we get some kind of better trait or abstract type for this).
I would also prefer to have the common case specialized so at least that gets to benefit from this.
I added a commit that only opted into this for "cpu strings". But note that this is really not the only place where this is done:
Regex (PCRE gets the pointer for any DenseUTF8String):
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/pcre.jl#L205-L213
Float parsing:
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/parse.jl#L264-L265
startswith / endswith (memcmp):
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/strings/util.jl#L73
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/strings/util.jl#L111
memchr / memrchr for any DenseArray{UInt8}:
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/strings/search.jl#L25-L27
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/strings/search.jl#L185-L186
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/strings/search.jl#L249-L250
IO: read! / write treat any DenseArray as contiguous and pass pointer(A) on:
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/reshapedarray.jl#L420
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/io.jl#L1020
https://github.com/JuliaLang/julia/blob/5900a4cf53eff80401f7b7f075f8563868869e03/base/io.jl#L943
As I wrote in https://github.com/JuliaLang/julia/pull/63375#issuecomment-5904051487
Alternatively, I wonder if the definitionDenseArrayshould be updated to say that the contents are stored contiguously in CPU memory. What is gained by allowing something like a GPU array to be aDenseArray? When would it be useful to dispatch to a specializedDenseArraymethod for a GPU array?
stevengj
nhz2
…ws (#62483)"
This reverts commit 8ffa5f0ef717148bf25c0a79ffaf202484784d13.
#62483 made assumptions about
DenseArraythat are not always true. These kinds of generic functions that usepointerare almost always going to be incorrect given the current state ofDenseArrayandpointer.Fixes #63361
CC: @jakobnissen @KristofferC