Skip to content

Commit 2f157a9

Browse files
committed
Don't muck with indices in unsafe indexing fallbacks
Simply pass everything straight through to the safe versions.
1 parent e66175b commit 2f157a9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

base/abstractarray.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ _unsafe_getindex(::LinearSlow, A::AbstractVector) = (@_inline_meta; unsafe_getin
478478
_unsafe_getindex(l::LinearSlow, A::AbstractArray) = (@_inline_meta; _unsafe_getindex(l, A, 1))
479479

480480
_getindex(::LinearIndexing, A::AbstractArray, I...) = error("indexing $(typeof(A)) with types $(typeof(I)) is not supported")
481-
_unsafe_getindex(::LinearIndexing, A::AbstractArray, I...) = error("indexing $(typeof(A)) with types $(typeof(I)) is not supported")
481+
_unsafe_getindex(::LinearIndexing, A::AbstractArray, I...) = (@_inline_meta; getindex(A, I...))
482482

483483
## LinearFast Scalar indexing
484484
_getindex(::LinearFast, A::AbstractArray, I::Int) = error("indexing not defined for ", typeof(A))
@@ -489,7 +489,7 @@ function _getindex(::LinearFast, A::AbstractArray, I::Real...)
489489
checkbounds(A, J...)
490490
unsafe_getindex(A, sub2ind(size(A), J...))
491491
end
492-
_unsafe_getindex(::LinearFast, A::AbstractArray, I::Int) = (@_inline_meta; getindex(A, I))
492+
_unsafe_getindex(::LinearFast, A::AbstractArray, I::Real) = (@_inline_meta; getindex(A, I))
493493
function _unsafe_getindex(::LinearFast, A::AbstractArray, I::Real...)
494494
@_inline_meta
495495
unsafe_getindex(A, sub2ind(size(A), to_indexes(I...)...))
@@ -531,8 +531,7 @@ end
531531
@generated function _unsafe_getindex{T,AN}(::LinearSlow, A::AbstractArray{T,AN}, I::Real...)
532532
N = length(I)
533533
if N == AN
534-
Isplat = Expr[:(to_index(I[$d])) for d = 1:N]
535-
:($(Expr(:meta, :inline)); getindex(A, $(Isplat...)))
534+
:($(Expr(:meta, :inline)); getindex(A, I...))
536535
elseif N > AN
537536
# Drop trailing dimensions (unchecked)
538537
Isplat = Expr[:(to_index(I[$d])) for d = 1:AN]
@@ -575,8 +574,9 @@ _unsafe_setindex!(::LinearFast, A::AbstractArray, v) = (@_inline_meta; unsafe_se
575574
_unsafe_setindex!{T}(::LinearSlow, A::AbstractArray{T,0}, v) = error("indexing not defined for ", typeof(A))
576575
_unsafe_setindex!(::LinearSlow, A::AbstractVector, v) = (@_inline_meta; unsafe_setindex!(A, v, 1))
577576
_unsafe_setindex!(l::LinearSlow, A::AbstractArray, v) = (@_inline_meta; _unsafe_setindex!(l, A, v, 1))
577+
578578
_setindex!(::LinearIndexing, A::AbstractArray, v, I...) = error("indexing $(typeof(A)) with types $(typeof(I)) is not supported")
579-
_unsafe_setindex!(::LinearIndexing, A::AbstractArray, v, I...) = error("indexing $(typeof(A)) with types $(typeof(I)) is not supported")
579+
_unsafe_setindex!(::LinearIndexing, A::AbstractArray, v, I...) = (@_inline_meta; setindex!(A, v, I...))
580580

581581
## LinearFast Scalar indexing
582582
_setindex!(::LinearFast, A::AbstractArray, v, I::Int) = error("indexed assignment not defined for ", typeof(A))
@@ -587,7 +587,7 @@ function _setindex!(::LinearFast, A::AbstractArray, v, I::Real...)
587587
checkbounds(A, J...)
588588
unsafe_setindex!(A, v, sub2ind(size(A), J...))
589589
end
590-
_unsafe_setindex!(::LinearFast, A::AbstractArray, v, I::Int) = (@_inline_meta; setindex!(A, v, I))
590+
_unsafe_setindex!(::LinearFast, A::AbstractArray, v, I::Real) = (@_inline_meta; setindex!(A, v, I))
591591
function _unsafe_setindex!(::LinearFast, A::AbstractArray, v, I::Real...)
592592
@_inline_meta
593593
unsafe_setindex!(A, v, sub2ind(size(A), to_indexes(I...)...))
@@ -628,8 +628,7 @@ end
628628
@generated function _unsafe_setindex!{T,AN}(::LinearSlow, A::AbstractArray{T,AN}, v, I::Real...)
629629
N = length(I)
630630
if N == AN
631-
Isplat = Expr[:(to_index(I[$d])) for d = 1:N]
632-
:(setindex!(A, v, $(Isplat...)))
631+
:(setindex!(A, v, I...))
633632
elseif N > AN
634633
# Drop trailing dimensions (unchecked)
635634
Isplat = Expr[:(to_index(I[$d])) for d = 1:AN]

0 commit comments

Comments
 (0)