Skip to content

Commit

Permalink
Make setindex!(::Array,x,::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 585fef0 commit 965f84e
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
Expand Up @@ -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))
Expand All @@ -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)
Expand Down

0 comments on commit 965f84e

Please sign in to comment.