@@ -13,7 +13,7 @@ struct OptionallyStaticUnitRange{F <: IntType, L <: IntType} <:
1313 stop:: L
1414
1515 function OptionallyStaticUnitRange (start:: IntType ,
16- stop:: IntType )
16+ stop:: IntType )
1717 new {typeof(start), typeof(stop)} (start, stop)
1818 end
1919 function OptionallyStaticUnitRange (start, stop)
@@ -57,39 +57,39 @@ static(2):static(2):10
5757```
5858"""
5959struct OptionallyStaticStepRange{F <: IntType , S <: IntType ,
60- L <: IntType } <: OrdinalRange{Int, Int}
60+ L <: IntType } <: OrdinalRange{Int, Int}
6161 start:: F
6262 step:: S
6363 stop:: L
6464
6565 global function _OptionallyStaticStepRange (@nospecialize (start:: IntType ),
66- @nospecialize (step:: IntType ),
67- @nospecialize (stop:: IntType ))
66+ @nospecialize (step:: IntType ),
67+ @nospecialize (stop:: IntType ))
6868 new {typeof(start), typeof(step), typeof(stop)} (start, step, stop)
6969 end
7070end
7171@noinline function OptionallyStaticStepRange (@nospecialize (start:: IntType ),
72- :: StaticInt{0} ,
73- @nospecialize (stop:: IntType ))
72+ :: StaticInt{0} ,
73+ @nospecialize (stop:: IntType ))
7474 throw (ArgumentError (" step cannot be zero" ))
7575end
7676# we don't need to check the `stop` if we know it acts like a unit range
7777function OptionallyStaticStepRange (@nospecialize (start:: IntType ),
78- step:: StaticInt{1} ,
79- @nospecialize (stop:: IntType ))
78+ step:: StaticInt{1} ,
79+ @nospecialize (stop:: IntType ))
8080 _OptionallyStaticStepRange (start, step, stop)
8181end
8282function OptionallyStaticStepRange (@nospecialize (start:: IntType ),
83- @nospecialize (step:: StaticInt ),
84- @nospecialize (stop:: IntType ))
83+ @nospecialize (step:: StaticInt ),
84+ @nospecialize (stop:: IntType ))
8585 _OptionallyStaticStepRange (start, step, _steprange_last (start, step, stop))
8686end
8787function OptionallyStaticStepRange (start, step, stop)
8888 OptionallyStaticStepRange (IntType (start), IntType (step), IntType (stop))
8989end
9090function OptionallyStaticStepRange (@nospecialize (start:: IntType ),
91- step:: Int ,
92- @nospecialize (stop:: IntType ))
91+ step:: Int ,
92+ @nospecialize (stop:: IntType ))
9393 if step === 0
9494 throw (ArgumentError (" step cannot be zero" ))
9595 else
9999OptionallyStaticStepRange (@nospecialize x:: OptionallyStaticStepRange ) = x
100100function OptionallyStaticStepRange (x:: AbstractRange )
101101 _OptionallyStaticStepRange (IntType (static_first (x)), IntType (static_step (x)),
102- IntType (static_last (x)))
102+ IntType (static_last (x)))
103103end
104104
105105# to make StepRange constructor inlineable, so optimizer can see `step` value
106106@inline function _steprange_last (start:: StaticInt , step:: StaticInt , stop:: StaticInt )
107107 StaticInt (_steprange_last (Int (start), Int (step), Int (stop)))
108108end
109109@inline function _steprange_last (start:: Union{StaticInt, Int} ,
110- step:: Union{StaticInt, Int} ,
111- stop:: Union{StaticInt, Int} )
110+ step:: Union{StaticInt, Int} ,
111+ stop:: Union{StaticInt, Int} )
112112 _steprange_last (Int (start), Int (step), Int (stop))
113113end
114114@inline function _steprange_last (start:: Int , step:: Int , stop:: Int )
@@ -147,7 +147,7 @@ SOneTo(n::Int) = SOneTo{n}()
147147Base. oneto (:: StaticInt{N} ) where {N} = SOneTo {N} ()
148148
149149const OptionallyStaticRange{F, L} = Union{OptionallyStaticUnitRange{F, L},
150- OptionallyStaticStepRange{F, <: Any , L}}
150+ OptionallyStaticStepRange{F, <: Any , L}}
151151
152152# these probide a generic method for extracting potentially static values.
153153static_first (x:: Base.OneTo ) = StaticInt (1 )
@@ -217,13 +217,13 @@ Base.isempty(r::OptionallyStaticUnitRange) = first(r) > last(r)
217217end
218218
219219function Base. checkindex (:: Type{Bool} ,
220- :: SUnitRange{F1, L1} ,
221- :: SUnitRange{F2, L2} ) where {F1, L1, F2, L2}
220+ :: SUnitRange{F1, L1} ,
221+ :: SUnitRange{F2, L2} ) where {F1, L1, F2, L2}
222222 (F1:: Int <= F2:: Int ) && (L1:: Int >= L2:: Int )
223223end
224224
225225function Base. getindex (r:: OptionallyStaticUnitRange ,
226- s:: AbstractUnitRange{<:Integer} )
226+ s:: AbstractUnitRange{<:Integer} )
227227 @boundscheck checkbounds (r, s)
228228 f = static_first (r)
229229 fnew = f - one (f)
@@ -299,11 +299,12 @@ end
299299function Base. axes1 (x:: OptionallyStaticStepRange )
300300 OptionallyStaticUnitRange (StaticInt (1 ), length (x))
301301end
302- function Base. axes1 (x:: OptionallyStaticStepRange{StaticInt{F}, StaticInt{S}, StaticInt{L}} ) where {
303- F,
304- S,
305- L
306- }
302+ function Base. axes1 (x:: OptionallyStaticStepRange {
303+ StaticInt{F}, StaticInt{S}, StaticInt{L}}) where {
304+ F,
305+ S,
306+ L
307+ }
307308 OptionallyStaticUnitRange (StaticInt (1 ), StaticInt (_range_length (F, S, L)))
308309end
309310Base. axes1 (x:: Base.Slice{<:OptionallyStaticUnitRange{One}} ) = x. indices
@@ -347,25 +348,25 @@ function Base.Broadcast.axistype(_, r::OptionallyStaticUnitRange{StaticInt{1}})
347348 Base. OneTo (last (r))
348349end
349350function Base. Broadcast. axistype (r:: OptionallyStaticUnitRange{StaticInt{1}} ,
350- :: OptionallyStaticUnitRange{StaticInt{1}} )
351+ :: OptionallyStaticUnitRange{StaticInt{1}} )
351352 Base. OneTo (last (r))
352353end
353354function Base. similar (:: Type{<:Array{T}} ,
354- axes:: Tuple {OptionallyStaticUnitRange{StaticInt{1 }},
355- Vararg{
356- Union{Base. OneTo,
357- OptionallyStaticUnitRange{StaticInt{1 }}}}}) where {
358- T
359- }
355+ axes:: Tuple {OptionallyStaticUnitRange{StaticInt{1 }},
356+ Vararg{
357+ Union{Base. OneTo,
358+ OptionallyStaticUnitRange{StaticInt{1 }}}}}) where {
359+ T
360+ }
360361 Array {T} (undef, map (last, axes))
361362end
362363function Base. similar (:: Type{<:Array{T}} ,
363- axes:: Tuple {Base. OneTo, OptionallyStaticUnitRange{StaticInt{1 }},
364- Vararg{
365- Union{Base. OneTo,
366- OptionallyStaticUnitRange{StaticInt{1 }}}}}) where {
367- T
368- }
364+ axes:: Tuple {Base. OneTo, OptionallyStaticUnitRange{StaticInt{1 }},
365+ Vararg{
366+ Union{Base. OneTo,
367+ OptionallyStaticUnitRange{StaticInt{1 }}}}}) where {
368+ T
369+ }
369370 Array {T} (undef, map (last, axes))
370371end
371372
0 commit comments