АО
import Base: getindex, size, setindex!
struct LinearSubArray{T} <: AbstractVector{T}
v::Vector{T}
offset::Int
len::Int
end
getindex(x::LinearSubArray, i) = @inbounds x.v[i + x.offset - 1]
setindex!(x::LinearSubArray, v, k) = @inbounds x.v[k + x.offset - 1] = v
size(x::LinearSubArray) = (x.len, )
lv = LinearSubArray(v2, 500, 1000);
julia> @btime sort!(vv) setup = (vv = deepcopy($v)) evals = 1;
13.110 μs (0 allocations: 0 bytes)
julia> @btime sort!(vv) setup = (vv = deepcopy($lv)) evals = 1;
12.037 μs (0 allocations: 0 bytes)
