@@ -125,11 +125,9 @@ module IteratorsMD
125125
126126 # comparison
127127 @inline isless (I1:: CartesianIndex{N} , I2:: CartesianIndex{N} ) where {N} = _isless (0 , I1. I, I2. I)
128- @inline function _isless (ret, I1:: Tuple{Int,Vararg{Int,N }} , I2:: Tuple{Int,Vararg{Int,N }} ) where {N}
128+ @inline function _isless (ret, I1:: Tuple{Int,Vararg{Int}} , I2:: Tuple{Int,Vararg{Int}} )
129129 newret = ifelse (ret== 0 , icmp (last (I1), last (I2)), ret)
130- t1, t2 = Base. front (I1), Base. front (I2)
131- # avoid dynamic dispatch by telling the compiler relational invariants
132- return isa (t1, Tuple{}) ? _isless (newret, (), ()) : _isless (newret, t1, t2:: Tuple{Int,Vararg{Int}} )
130+ return _isless (newret, Base. front (I1), Base. front (I2))
133131 end
134132 _isless (ret, :: Tuple{} , :: Tuple{} ) = ifelse (ret== 1 , true , false )
135133 icmp (a, b) = ifelse (isless (a,b), 1 , ifelse (a== b, 0 , - 1 ))
@@ -409,15 +407,13 @@ module IteratorsMD
409407 valid = __is_valid_range (I, rng) && state[1 ] != last (rng)
410408 return valid, (I, )
411409 end
412- @inline function __inc (state:: Tuple{Int,Int,Vararg{Int,N }} , indices:: Tuple{OrdinalRangeInt,OrdinalRangeInt,Vararg{OrdinalRangeInt,N }} ) where {N}
410+ @inline function __inc (state:: Tuple{Int,Int,Vararg{Int}} , indices:: Tuple{OrdinalRangeInt,OrdinalRangeInt,Vararg{OrdinalRangeInt}} )
413411 rng = indices[1 ]
414412 I = state[1 ] + step (rng)
415413 if __is_valid_range (I, rng) && state[1 ] != last (rng)
416414 return true , (I, tail (state)... )
417415 end
418- t1, t2 = tail (state), tail (indices)
419- # avoid dynamic dispatch by telling the compiler relational invariants
420- valid, I = isa (t1, Tuple{Int}) ? __inc (t1, t2:: Tuple{OrdinalRangeInt} ) : __inc (t1, t2:: Tuple{OrdinalRangeInt,OrdinalRangeInt,Vararg{OrdinalRangeInt}} )
416+ valid, I = __inc (tail (state), tail (indices))
421417 return valid, (first (rng), I... )
422418 end
423419
@@ -522,15 +518,13 @@ module IteratorsMD
522518 valid = __is_valid_range (I, rng) && state[1 ] != first (rng)
523519 return valid, (I,)
524520 end
525- @inline function __dec (state:: Tuple{Int,Int,Vararg{Int,N }} , indices:: Tuple{OrdinalRangeInt,OrdinalRangeInt,Vararg{OrdinalRangeInt,N }} ) where {N}
521+ @inline function __dec (state:: Tuple{Int,Int,Vararg{Int}} , indices:: Tuple{OrdinalRangeInt,OrdinalRangeInt,Vararg{OrdinalRangeInt}} )
526522 rng = indices[1 ]
527523 I = state[1 ] - step (rng)
528524 if __is_valid_range (I, rng) && state[1 ] != first (rng)
529525 return true , (I, tail (state)... )
530526 end
531- t1, t2 = tail (state), tail (indices)
532- # avoid dynamic dispatch by telling the compiler relational invariants
533- valid, I = isa (t1, Tuple{Int}) ? __dec (t1, t2:: Tuple{OrdinalRangeInt} ) : __dec (t1, t2:: Tuple{OrdinalRangeInt,OrdinalRangeInt,Vararg{OrdinalRangeInt}} )
527+ valid, I = __dec (tail (state), tail (indices))
534528 return valid, (last (rng), I... )
535529 end
536530
0 commit comments