Skip to content

Commit 03cc7d2

Browse files
author
Ian Atol
authored
Change __getindex_dims to work better with inference (#100)
1 parent 145b0fa commit 03cc7d2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/FlexTable.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ function Base.view(t::FlexTable, inds::Union{AbstractArray, Colon}...)
232232
return FlexTable{_getindex_dims(inds)}(map(col -> view(col, inds...), columns(t)))
233233
end
234234

235-
@inline _getindex_dims(inds) = __getindex_dims(0, inds...)
236-
@inline __getindex_dims(n::Int) = n
237-
@inline __getindex_dims(n::Int, ::Int, inds...) = __getindex_dims(n, inds...)
238-
@inline __getindex_dims(n::Int, ::AbstractArray{<:Any, m}, inds...) where {m} = __getindex_dims(n + m, inds...)
239-
@inline __getindex_dims(n::Int, ::Colon, inds...) = __getindex_dims(n + 1, inds...)
235+
@inline _getindex_dims(inds) = __getindex_dims(inds...)
236+
@inline __getindex_dims() = 0
237+
@inline __getindex_dims(::Int, inds...) = __getindex_dims(inds...)
238+
@inline __getindex_dims(::AbstractArray{<:Any, m}, inds...) where {m} = __getindex_dims(inds...) + m
239+
@inline __getindex_dims(::Colon, inds...) = __getindex_dims(inds...) + 1
240240

241241
# Deprecated for .= syntax (via Base.Broadcast.materialize!)
242242
# It seems `Ref` might be the new cool here. Could also consider `AbstractArray{<:NamedTuple, 0}`?

0 commit comments

Comments
 (0)