File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ julia> axes(A)
95
95
"""
96
96
function axes (A)
97
97
@inline
98
- map (oneto , size (A))
98
+ map (unchecked_oneto , size (A))
99
99
end
100
100
101
101
"""
Original file line number Diff line number Diff line change @@ -447,7 +447,7 @@ distinction that the lower limit is guaranteed (by the type system) to
447
447
be 1.
448
448
"""
449
449
struct OneTo{T<: Integer } <: AbstractUnitRange{T}
450
- stop:: T
450
+ stop:: T # invariant: stop >= zero(stop)
451
451
function OneTo {T} (stop) where {T<: Integer }
452
452
throwbool (r) = (@noinline ; throw (ArgumentError (" invalid index: $r of type Bool" )))
453
453
T === Bool && throwbool (stop)
@@ -463,6 +463,8 @@ struct OneTo{T<:Integer} <: AbstractUnitRange{T}
463
463
T === Bool && throwbool (r)
464
464
return new (max (zero (T), last (r)))
465
465
end
466
+
467
+ global unchecked_oneto (stop:: Integer ) = new {typeof(stop)} (stop)
466
468
end
467
469
OneTo (stop:: T ) where {T<: Integer } = OneTo {T} (stop)
468
470
OneTo (r:: AbstractRange{T} ) where {T<: Integer } = OneTo {T} (r)
@@ -703,8 +705,6 @@ step(r::LinRange) = (last(r)-first(r))/r.lendiv
703
705
step_hp (r:: StepRangeLen ) = r. step
704
706
step_hp (r:: AbstractRange ) = step (r)
705
707
706
- axes (r:: AbstractRange ) = (oneto (length (r)),)
707
-
708
708
# Needed to ensure `has_offset_axes` can constant-fold.
709
709
has_offset_axes (:: StepRange ) = false
710
710
You can’t perform that action at this time.
0 commit comments