Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/impl/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ end
return fallback()
end

@inline function terminating_foldlargs(op, fallback, x1, x2, x3)
acc = op(x1, x2)
acc isa Reduced && return unreduced(acc)
acc = op(acc, x3)
acc isa Reduced && return unreduced(acc)
return fallback()
end


struct Padded{T, N}
value::T
Expand Down
15 changes: 10 additions & 5 deletions src/impl/vectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,19 @@ end
# Base.checkbounds(::Type{Bool}, A::UnionVector, i) =
# checkbounds(Bool, A.data, i) && checkbounds(Bool, A.typeid, i)

@inline function Base.setindex!(A::UnionVector, v, i::Int)
@inline function Base.setindex!(A::UnionVector, v::T, i::Int) where {T}
@noinline unreachable() = throw(ElTypeLookupFailed{nothing}())
@boundscheck checkbounds(A, i)
typeid = A.typeid
view_and_id(A, typeof(v)) do xs, id
return terminating_foldlargs(unreachable, (v, 1), A.views...) do (v, id), xs
Base.@_inline_meta
@inbounds typeid[i] = id
@inbounds xs[i] = v
nothing
if v isa paddedtype(eltype(xs))
@inbounds typeid[i] = id
@inbounds xs[i] = v
Reduced(nothing)
else
(v, id + 1)
end
end
end

Expand Down