Skip to content

Commit

Permalink
Fix type stability of Base.to_index for long tuples
Browse files Browse the repository at this point in the history
Helps #9622; getindex is now inlined up to N=6 and setindex! up to N=5. Any higher dimensions are limited by MAX_TUPLETYPE_LEN.
  • Loading branch information
mbauman committed Jun 20, 2015
1 parent 29f3cb5 commit 6a3c173
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,8 @@ to_index(i1, i2) = to_index(i1), to_index(i2)
to_index(i1, i2, i3) = to_index(i1), to_index(i2), to_index(i3)
to_index(i1, i2, i3, i4) = to_index(i1), to_index(i2), to_index(i3), to_index(i4)
to_index(I...) = to_index(I)
to_index(I::Tuple{Any,}) = (to_index(I[1]), )
to_index(I::Tuple{Any,Any,}) = (to_index(I[1]), to_index(I[2]))
to_index(I::Tuple{Any,Any,Any}) = (to_index(I[1]), to_index(I[2]), to_index(I[3]))
to_index(I::Tuple{Any,Any,Any,Any}) = (to_index(I[1]), to_index(I[2]), to_index(I[3]), to_index(I[4]))
to_index(I::Tuple) = map(to_index, I)
to_index(I::Tuple{}) = ()
to_index(I::Tuple) = (to_index(I[1]), to_index(tail(I))...)
to_index(i) = error("invalid index: $i")

# Addition/subtraction of ranges
Expand Down

0 comments on commit 6a3c173

Please sign in to comment.