From 965f84e1b33a498241b4d91d273f0936a9348cce Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Thu, 4 Jun 2015 10:26:15 -0400 Subject: [PATCH] Make setindex!(::Array,x,::Colon) available in coreimg --- base/array.jl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/base/array.jl b/base/array.jl index c7fbb35f46150..ea1770ea82235 100644 --- a/base/array.jl +++ b/base/array.jl @@ -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)