|
95 | 95 | return dest |
96 | 96 | end |
97 | 97 |
|
98 | | -Base.@propagate_inbounds catvec_broadcast_vec(x::CatVector, k::Int) = x.vecs[k] |
99 | | -Base.@propagate_inbounds catvec_broadcast_vec(x::Number, k::Int) = x |
| 98 | +Base.@propagate_inbounds catvec_broadcast_vec(arg::CatVector, range::UnitRange, k::Int) = arg.vecs[k] |
| 99 | +Base.@propagate_inbounds catvec_broadcast_vec(arg::AbstractVector, range::UnitRange, k::Int) = view(arg, range) |
| 100 | +Base.@propagate_inbounds catvec_broadcast_vec(arg::Number, range::UnitRange, k::Int) = arg |
100 | 101 |
|
101 | 102 | @inline function Base.copyto!(dest::CatVector, bc::Broadcast.Broadcasted{Nothing}) |
102 | 103 | flat = Broadcast.flatten(bc) |
103 | 104 | @boundscheck check_cat_vectors_line_up(dest, flat.args...) |
| 105 | + offset = 1 |
104 | 106 | @inbounds for i in eachindex(dest.vecs) |
105 | 107 | let i = i, f = flat.f, args = flat.args |
106 | | - dest′ = catvec_broadcast_vec(dest, i) |
107 | | - args′ = map(arg -> catvec_broadcast_vec(arg, i), args) |
| 108 | + dest′ = dest.vecs[i] |
| 109 | + range = offset : offset + length(dest′) - 1 |
| 110 | + args′ = map(arg -> catvec_broadcast_vec(arg, range, i), args) |
108 | 111 | axes′ = (eachindex(dest′),) |
109 | 112 | copyto!(dest′, Broadcast.Broadcasted{Nothing}(f, args′, axes′)) |
| 113 | + offset = last(range) + 1 |
110 | 114 | end |
111 | 115 | end |
112 | 116 | return dest |
|
0 commit comments