Skip to content

Commit

Permalink
optimize get_ith (#286)
Browse files Browse the repository at this point in the history

Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>
  • Loading branch information
aplavin and piever authored Feb 23, 2024
1 parent 2ae2909 commit 3880403
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/structarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,7 @@ to
map(c -> c[I...], Tuple(cols))
```
"""
@inline get_ith(cols::NamedTuple, I...) = get_ith(Tuple(cols), I...)
@inline function get_ith(cols::Tuple, I...)
@inbounds r = first(cols)[I...]
return (r, get_ith(Base.tail(cols), I...)...)
end
@inline get_ith(::Tuple{}, I...) = ()
@inline @generated get_ith(cols::Tup, I...) = :(Base.Cartesian.@ntuple $(fieldcount(cols)) i -> @inbounds cols[i][I...])

Base.@propagate_inbounds Base.getindex(x::StructArray, I...) = _getindex(x, to_indices(x, I)...)

Expand Down

0 comments on commit 3880403

Please sign in to comment.