@@ -125,11 +125,9 @@ module IteratorsMD
125
125
126
126
# comparison
127
127
@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}} )
129
129
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))
133
131
end
134
132
_isless (ret, :: Tuple{} , :: Tuple{} ) = ifelse (ret== 1 , true , false )
135
133
icmp (a, b) = ifelse (isless (a,b), 1 , ifelse (a== b, 0 , - 1 ))
@@ -409,15 +407,13 @@ module IteratorsMD
409
407
valid = __is_valid_range (I, rng) && state[1 ] != last (rng)
410
408
return valid, (I, )
411
409
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}} )
413
411
rng = indices[1 ]
414
412
I = state[1 ] + step (rng)
415
413
if __is_valid_range (I, rng) && state[1 ] != last (rng)
416
414
return true , (I, tail (state)... )
417
415
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))
421
417
return valid, (first (rng), I... )
422
418
end
423
419
@@ -522,15 +518,13 @@ module IteratorsMD
522
518
valid = __is_valid_range (I, rng) && state[1 ] != first (rng)
523
519
return valid, (I,)
524
520
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}} )
526
522
rng = indices[1 ]
527
523
I = state[1 ] - step (rng)
528
524
if __is_valid_range (I, rng) && state[1 ] != first (rng)
529
525
return true , (I, tail (state)... )
530
526
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))
534
528
return valid, (last (rng), I... )
535
529
end
536
530
0 commit comments