Skip to content

Commit 50e75a3

Browse files
committed
Use Base.length rather than dynamic(length(...))
1 parent 13c072f commit 50e75a3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/ArrayInterface.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ static(12)
5454
"""
5555
@inline length(a::UnitRange{T}) where {T} = last(a) - first(a) + oneunit(T)
5656
@inline length(x) = Static.maybe_static(known_length, Base.length, x)
57-
const static_length = length # for backward compatibility
57+
58+
# Alias to to-be-depreciated internal function
59+
const static_length = length
5860

5961
@inline static_first(x) = Static.maybe_static(known_first, first, x)
6062
@inline static_last(x) = Static.maybe_static(known_last, last, x)

src/indexing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ indices calling [`to_axis`](@ref).
243243
@inline function to_axes(A, inds::Tuple)
244244
if ndims(A) === 1
245245
return (to_axis(axes(A, 1), first(inds)),)
246-
elseif dynamic(length(inds)) === 1
246+
elseif Base.length(inds) === 1
247247
return (to_axis(eachindex(IndexLinear(), A), first(inds)),)
248248
else
249249
return to_axes(A, axes(A), inds)
@@ -378,14 +378,14 @@ end
378378
_ints2range(x::Integer) = x:x
379379
_ints2range(x::AbstractRange) = x
380380
@inline function unsafe_get_collection(A::CartesianIndices{N}, inds) where {N}
381-
if (dynamic(length(inds)) === 1 && N > 1) || stride_preserving_index(typeof(inds)) === False()
381+
if (Base.length(inds) === 1 && N > 1) || stride_preserving_index(typeof(inds)) === False()
382382
return Base._getindex(IndexStyle(A), A, inds...)
383383
else
384384
return CartesianIndices(to_axes(A, _ints2range.(inds)))
385385
end
386386
end
387387
@inline function unsafe_get_collection(A::LinearIndices{N}, inds) where {N}
388-
if dynamic(length(inds)) === 1 && isone(_ndims_index(typeof(inds), static(1)))
388+
if Base.length(inds) === 1 && isone(_ndims_index(typeof(inds), static(1)))
389389
return @inbounds(eachindex(A)[first(inds)])
390390
elseif stride_preserving_index(typeof(inds)) === True()
391391
return LinearIndices(to_axes(A, _ints2range.(inds)))

0 commit comments

Comments
 (0)