Skip to content

Commit

Permalink
improve types in UnitRange constructor
Browse files Browse the repository at this point in the history
the `ifelse` was type-unstable in some caes, for example Bool where
`start-one(stop-start)` gives an Int.
  • Loading branch information
JeffBezanson committed Jan 4, 2015
1 parent e34aad8 commit fb342cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ immutable UnitRange{T<:Real} <: OrdinalRange{T,Int}
start::T
stop::T

UnitRange(start, stop) = new(start, ifelse(stop >= start, stop, start-one(stop-start)))
UnitRange(start, stop) =
new(start, ifelse(stop >= start, stop, convert(T,start-one(stop-start))))
end
UnitRange{T<:Real}(start::T, stop::T) = UnitRange{T}(start, stop)

Expand Down

0 comments on commit fb342cb

Please sign in to comment.