Skip to content

Commit

Permalink
Restore repeat preformance for arrays of scalars (#24022)
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz authored and ararslan committed Oct 6, 2017
1 parent a7e7a33 commit af5abb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ _rshps(shp, shp_i, sz, i, ::Tuple{}) =
_reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " *
"($n) cannot be less than number of dimensions of input ($N)"))

# We need special handling when repeating arrays of arrays
cat_fill!(R, X, inds) = (R[inds...] = X)
cat_fill!(R, X::AbstractArray, inds) = fill!(view(R, inds...), X)

@noinline function _repeat(A::AbstractArray, inner, outer)
shape, inner_shape = rep_shapes(A, inner, outer)

Expand All @@ -442,7 +446,7 @@ _reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " *
n = inner[i]
inner_indices[i] = (1:n) .+ ((c[i] - 1) * n)
end
fill!(view(R, inner_indices...), A[c])
cat_fill!(R, A[c], inner_indices)
end
end

Expand Down

0 comments on commit af5abb3

Please sign in to comment.