Skip to content

Commit f93c6ef

Browse files
committed
improve compiler performance
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)
1 parent e1f42b1 commit f93c6ef

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

base/tuple.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ firstindex(@nospecialize t::Tuple) = 1
2121
lastindex(@nospecialize t::Tuple) = length(t)
2222
size(@nospecialize(t::Tuple), d) = (d == 1) ? length(t) : throw(ArgumentError("invalid tuple dimension $d"))
2323
axes(@nospecialize t::Tuple) = OneTo(length(t))
24-
@eval getindex(t::Tuple, i::Int) = getfield(t, i, $(Expr(:boundscheck)))
25-
@eval getindex(t::Tuple, i::Real) = getfield(t, convert(Int, i), $(Expr(:boundscheck)))
24+
@eval getindex(@nospecialize(t::Tuple), i::Int) = getfield(t, i, $(Expr(:boundscheck)))
25+
@eval getindex(@nospecialize(t::Tuple), i::Real) = getfield(t, convert(Int, i), $(Expr(:boundscheck)))
2626
getindex(t::Tuple, r::AbstractArray{<:Any,1}) = ([t[ri] for ri in r]...,)
2727
getindex(t::Tuple, b::AbstractArray{Bool,1}) = length(b) == length(t) ? getindex(t, findall(b)) : throw(BoundsError(t, b))
2828
getindex(t::Tuple, c::Colon) = t
@@ -38,7 +38,10 @@ _setindex(v, i::Integer) = ()
3838

3939
## iterating ##
4040

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

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

0 commit comments

Comments
 (0)