@@ -301,22 +301,20 @@ end
301301@inline function _try_static (:: StaticInt{M} , :: StaticInt{N} ) where {M,N}
302302 @assert false " Unequal Indices: StaticInt{$M }() != StaticInt{$N }()"
303303end
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
304308@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)
308310 return StaticInt {N} ()
309311end
310312@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} ())
314314 return StaticInt {N} ()
315315end
316316@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)
320318 return x
321319end
322320
@@ -407,15 +405,15 @@ Base.eachindex(r::OptionallyStaticRange) = r
407405Base. to_shape (x:: OptionallyStaticRange ) = length (x)
408406Base. to_shape (x:: Slice{T} ) where {T<: OptionallyStaticRange } = length (x)
409407
410- function Base. axes (S:: Slice{T} ) where {T<: OptionallyStaticRange }
408+ @inline function Base. axes (S:: Slice{T} ) where {T<: OptionallyStaticRange }
411409 if known_first (T) === 1 && known_step (T) === 1
412410 return (S. indices,)
413411 else
414412 return (Base. IdentityUnitRange (S. indices),)
415413 end
416414end
417415
418- function Base. axes1 (S:: Slice{T} ) where {T<: OptionallyStaticRange }
416+ @inline function Base. axes1 (S:: Slice{T} ) where {T<: OptionallyStaticRange }
419417 if known_first (T) === 1 && known_step (T) === 1
420418 return S. indices
421419 else
0 commit comments