Skip to content

Commit

Permalink
Make indexing Array with Colon available in coreimg
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Jun 4, 2015
1 parent a679a06 commit 82b5024
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
@@ -347,6 +347,20 @@ function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int})
end
return A
end
function setindex!(A::Array, x, ::Colon)
for i in 1:length(A)
@inbounds A[i] = x
end
return A
end
function setindex!(A::Array, X::AbstractArray, ::Colon)
setindex_shape_check(X, length(A))
i = 0
for x in X
@inbounds A[i+=1] = x
end
return A
end

# Faster contiguous setindex! with copy!
setindex!{T}(A::Array{T}, X::Array{T}, I::UnitRange{Int}) = (checkbounds(A, I); unsafe_setindex!(A, X, I))
@@ -368,7 +382,6 @@ function unsafe_setindex!{T}(A::Array{T}, X::Array{T}, ::Colon)
return A
end


# efficiently grow an array

function _growat!(a::Vector, i::Integer, delta::Integer)

0 comments on commit 82b5024

Please sign in to comment.