314314function getindex (V:: FastContiguousSubArray , i:: AbstractUnitRange{Int} )
315315 @inline
316316 @boundscheck checkbounds (V, i)
317- out = similar (V, axes (i))
318- li = length (i)
319- if li > 0
320- copyto! (out, firstindex (out), V. parent, V. offset1 + first (i), li)
321- end
322- return out
317+ @inbounds r = V. parent[V. offset1 .+ i]
318+ r
323319end
324320
325321# For vector views with linear indexing, we disambiguate to favor the stride/offset
@@ -336,16 +332,6 @@ function getindex(V::FastContiguousSubArray{<:Any, 1}, i::Int)
336332 @inbounds r = V. parent[V. offset1 + i]
337333 r
338334end
339- function getindex (V:: FastContiguousSubArray{<:Any, 1} , i:: AbstractUnitRange{Int} )
340- @inline
341- @boundscheck checkbounds (V, i)
342- out = similar (V, axes (i))
343- li = length (i)
344- if li > 0
345- copyto! (out, firstindex (out), V. parent, V. offset1 + first (i), li)
346- end
347- return out
348- end
349335@inline getindex (V:: FastContiguousSubArray , i:: Colon ) = getindex (V, to_indices (V, (:,))... )
350336
351337# Indexed assignment follows the same pattern as `getindex` above
@@ -367,26 +353,23 @@ function setindex!(V::FastContiguousSubArray, x, i::Int)
367353 @inbounds V. parent[V. offset1 + i] = x
368354 V
369355end
370- function setindex! (V:: FastContiguousSubArray , x, i:: AbstractUnitRange{Int} )
356+ function setindex! (V:: FastSubArray , x, i:: AbstractUnitRange{Int} )
371357 @inline
372358 @boundscheck checkbounds (V, i)
373- li = length (i)
374- if li > 0
375- copyto! (V. parent, V. offset1 + first (i), x, firstindex (x), li)
376- end
359+ @inbounds V. parent[V. offset1 .+ V. stride1 .* i] = x
377360 V
378361end
379-
380- function setindex! (V:: FastSubArray{<:Any, 1} , x, i:: Int )
362+ function setindex! (V:: FastContiguousSubArray , x, i:: AbstractUnitRange{Int} )
381363 @inline
382364 @boundscheck checkbounds (V, i)
383- @inbounds V. parent[V. offset1 + V . stride1 * i] = x
365+ @inbounds V. parent[V. offset1 .+ i] = x
384366 V
385367end
386- function setindex! (V:: FastSubArray{<:Any, 1} , x, i:: AbstractUnitRange{Int} )
368+
369+ function setindex! (V:: FastSubArray{<:Any, 1} , x, i:: Int )
387370 @inline
388371 @boundscheck checkbounds (V, i)
389- @inbounds V. parent[V. offset1 . + V. stride1 .* i] = x
372+ @inbounds V. parent[V. offset1 + V. stride1* i] = x
390373 V
391374end
392375function setindex! (V:: FastContiguousSubArray{<:Any, 1} , x, i:: Int )
@@ -395,15 +378,6 @@ function setindex!(V::FastContiguousSubArray{<:Any, 1}, x, i::Int)
395378 @inbounds V. parent[V. offset1 + i] = x
396379 V
397380end
398- function setindex! (V:: FastContiguousSubArray{<:Any, 1} , x, i:: AbstractUnitRange{Int} )
399- @inline
400- @boundscheck checkbounds (V, i)
401- li = length (i)
402- if li > 0
403- copyto! (V. parent, V. offset1 + first (i), x, firstindex (x), li)
404- end
405- V
406- end
407381@inline setindex! (V:: FastSubArray , x, i:: Colon ) = setindex! (V, x, to_indices (V, (i,))... )
408382
409383function isassigned (V:: SubArray{T,N} , I:: Vararg{Int,N} ) where {T,N}
0 commit comments