Skip to content

Commit

Permalink
improve compiler performance
Browse files Browse the repository at this point in the history
somehow these were missed in the last round of `nospecialize` annotations in this file,
but these are also very important for compiler performance
(especially as we have now been adding more places where we inspect tuples with this method)
  • Loading branch information
vtjnash committed Sep 28, 2018
1 parent e1f42b1 commit f93c6ef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions base/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ firstindex(@nospecialize t::Tuple) = 1
lastindex(@nospecialize t::Tuple) = length(t)
size(@nospecialize(t::Tuple), d) = (d == 1) ? length(t) : throw(ArgumentError("invalid tuple dimension $d"))
axes(@nospecialize t::Tuple) = OneTo(length(t))
@eval getindex(t::Tuple, i::Int) = getfield(t, i, $(Expr(:boundscheck)))
@eval getindex(t::Tuple, i::Real) = getfield(t, convert(Int, i), $(Expr(:boundscheck)))
@eval getindex(@nospecialize(t::Tuple), i::Int) = getfield(t, i, $(Expr(:boundscheck)))
@eval getindex(@nospecialize(t::Tuple), i::Real) = getfield(t, convert(Int, i), $(Expr(:boundscheck)))
getindex(t::Tuple, r::AbstractArray{<:Any,1}) = ([t[ri] for ri in r]...,)
getindex(t::Tuple, b::AbstractArray{Bool,1}) = length(b) == length(t) ? getindex(t, findall(b)) : throw(BoundsError(t, b))
getindex(t::Tuple, c::Colon) = t
Expand All @@ -38,7 +38,10 @@ _setindex(v, i::Integer) = ()

## iterating ##

iterate(t::Tuple, i::Int=1) = 1 <= i <= length(t) ? (@inbounds t[i], i+1) : nothing
function iterate(@nospecialize(t::Tuple), i::Int=1)
@_inline_meta
return (1 <= i <= length(t)) ? (@inbounds t[i], i + 1) : nothing
end

keys(@nospecialize t::Tuple) = OneTo(length(t))

Expand Down

0 comments on commit f93c6ef

Please sign in to comment.