Skip to content

Commit

Permalink
directly call arrayset/arrayref
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutho committed Jan 6, 2015
1 parent e26eb53 commit c4cfc68
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ end
# indexing
getindex(index::CartesianIndex, i::Integer) = getfield(index, i)

stagedfunction getindex{N}(A::Array, index::CartesianIndex{N})
N==0 ? :(Base.arrayref(A, 1)) : :(@ncall $N Base.arrayref A d->getfield(index,d))
end
stagedfunction setindex!{T,N}(A::Array{T}, v, index::CartesianIndex{N})
N==0 ? :(Base.arrayset(A, convert($T,v), 1)) : :(@ncall $N Base.arrayset A convert($T,v) d->getfield(index,d))
end

stagedfunction getindex{N}(A::AbstractArray, index::CartesianIndex{N})
:(@nref $N A d->getfield(index,d))
end
Expand Down

0 comments on commit c4cfc68

Please sign in to comment.