From 6a3c173633a8c019177daad7d752f0aa69bd621d Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Fri, 19 Jun 2015 22:46:06 -0400 Subject: [PATCH] Fix type stability of Base.to_index for long tuples 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. --- base/operators.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/base/operators.jl b/base/operators.jl index bd8e3018b9be1..961244e878747 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -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