Skip to content

Commit

Permalink
Move setindex! with Colon from array.jl to arraymath.jl
Browse files Browse the repository at this point in the history
hopefully fixes win64 inference freeze
  • Loading branch information
tkelman committed Jun 12, 2015
1 parent f5f4ea0 commit 2fe0d94
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
14 changes: 0 additions & 14 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,6 @@ 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 Down
16 changes: 16 additions & 0 deletions base/arraymath.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

## setindex! with Colon
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

## Unary operators ##

function conj!{T<:Number}(A::AbstractArray{T})
Expand Down
2 changes: 1 addition & 1 deletion base/intset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ symdiff(s1::IntSet, s2::IntSet) =
(s1.limit >= s2.limit ? symdiff!(copy(s1), s2) : symdiff!(copy(s2), s1))

function empty!(s::IntSet)
s.bits[:] = 0
fill!(s.bits, 0)
return s
end

Expand Down

0 comments on commit 2fe0d94

Please sign in to comment.