Skip to content

Commit 3880403

Browse files
aplavinpiever
andauthored
optimize get_ith (#286)
Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>
1 parent 2ae2909 commit 3880403

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/structarray.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,7 @@ to
338338
map(c -> c[I...], Tuple(cols))
339339
```
340340
"""
341-
@inline get_ith(cols::NamedTuple, I...) = get_ith(Tuple(cols), I...)
342-
@inline function get_ith(cols::Tuple, I...)
343-
@inbounds r = first(cols)[I...]
344-
return (r, get_ith(Base.tail(cols), I...)...)
345-
end
346-
@inline get_ith(::Tuple{}, I...) = ()
341+
@inline @generated get_ith(cols::Tup, I...) = :(Base.Cartesian.@ntuple $(fieldcount(cols)) i -> @inbounds cols[i][I...])
347342

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

0 commit comments

Comments
 (0)