Skip to content

Commit f44c82b

Browse files
committed
Add faster static_length implementation for UnitRanges.
1 parent d68b119 commit f44c82b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/static.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ end
127127
return StaticInt(L)
128128
end
129129
end
130+
@inline static_length(a::UnitRange{T}) where {T} = last(a) - first(a) + oneunit(T)
130131
@inline static_length(x) = maybe_static(known_length, length, x)
131132
@inline static_first(x) = maybe_static(known_first, first, x)
132133
@inline static_last(x) = maybe_static(known_last, last, x)

0 commit comments

Comments
 (0)