@@ -301,22 +301,20 @@ end
301
301
@inline function _try_static (:: StaticInt{M} , :: StaticInt{N} ) where {M,N}
302
302
@assert false " Unequal Indices: StaticInt{$M }() != StaticInt{$N }()"
303
303
end
304
+ @noinline unequal_error (x,y) = throw (" Unequal Indices: x == $x != $y == y" )
305
+ @inline function check_equal (x, y)
306
+ x == y || unequal_error (x,y)
307
+ end
304
308
@propagate_inbounds function _try_static (:: StaticInt{N} , x) where {N}
305
- @boundscheck begin
306
- @assert N == x " Unequal Indices: StaticInt{$N }() != x == $x "
307
- end
309
+ @boundscheck check_equal (StaticInt {N} (), x)
308
310
return StaticInt {N} ()
309
311
end
310
312
@propagate_inbounds function _try_static (x, :: StaticInt{N} ) where {N}
311
- @boundscheck begin
312
- @assert N == x " Unequal Indices: x == $x != StaticInt{$N }()"
313
- end
313
+ @boundscheck check_equal (x, StaticInt {N} ())
314
314
return StaticInt {N} ()
315
315
end
316
316
@propagate_inbounds function _try_static (x, y)
317
- @boundscheck begin
318
- @assert x == y " Unequal Indices: x == $x != $y == y"
319
- end
317
+ @boundscheck check_equal (x, y)
320
318
return x
321
319
end
322
320
@@ -407,15 +405,15 @@ Base.eachindex(r::OptionallyStaticRange) = r
407
405
Base. to_shape (x:: OptionallyStaticRange ) = length (x)
408
406
Base. to_shape (x:: Slice{T} ) where {T<: OptionallyStaticRange } = length (x)
409
407
410
- function Base. axes (S:: Slice{T} ) where {T<: OptionallyStaticRange }
408
+ @inline function Base. axes (S:: Slice{T} ) where {T<: OptionallyStaticRange }
411
409
if known_first (T) === 1 && known_step (T) === 1
412
410
return (S. indices,)
413
411
else
414
412
return (Base. IdentityUnitRange (S. indices),)
415
413
end
416
414
end
417
415
418
- function Base. axes1 (S:: Slice{T} ) where {T<: OptionallyStaticRange }
416
+ @inline function Base. axes1 (S:: Slice{T} ) where {T<: OptionallyStaticRange }
419
417
if known_first (T) === 1 && known_step (T) === 1
420
418
return S. indices
421
419
else
0 commit comments