Skip to content

Commit

Permalink
Use foldl in multicol setindex
Browse files Browse the repository at this point in the history
  • Loading branch information
bgroenks96 committed Feb 11, 2022
1 parent b06ea0b commit a19832c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,9 @@ end
@inline Base.setindex(m::AbstractModel, xs, i::Integer, ::Colon) = Base.setindex(m, xs, i, filter(!_isreserved, keys(m)))
@inline Base.setindex(m::AbstractModel, xs, i::Integer, ::Type{Val{col}}) where col = _setindex(m, xs, i, Val{col})
@inline function Base.setindex(m::AbstractModel, xs, i::RowIndexer, cols::Union{Tuple,AbstractVector})
for col in cols
m = Base.setindex(m, Tables.getcolumn(xs, col), i, Val{col})
return foldl(cols; init=m) do m, col
Base.setindex(m, Tables.getcolumn(xs, col), i, col)
end
return m
end
@inline function Base.setindex(m::AbstractModel, xs, i::AbstractVector{<:Integer}, ::Type{Val{col}}) where col
@assert !_isreserved(col) "column name :$col is reserved and cannot be modified"
Expand Down

0 comments on commit a19832c

Please sign in to comment.