Skip to content

Commit 82b5024

Browse files
committed
Make indexing Array with Colon available in coreimg
1 parent a679a06 commit 82b5024

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

base/array.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,20 @@ function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int})
347347
end
348348
return A
349349
end
350+
function setindex!(A::Array, x, ::Colon)
351+
for i in 1:length(A)
352+
@inbounds A[i] = x
353+
end
354+
return A
355+
end
356+
function setindex!(A::Array, X::AbstractArray, ::Colon)
357+
setindex_shape_check(X, length(A))
358+
i = 0
359+
for x in X
360+
@inbounds A[i+=1] = x
361+
end
362+
return A
363+
end
350364

351365
# Faster contiguous setindex! with copy!
352366
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)
368382
return A
369383
end
370384

371-
372385
# efficiently grow an array
373386

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

0 commit comments

Comments
 (0)