Skip to content

Commit f0f9e74

Browse files
committed
Reduce invalidations of other methods
These changes, combined with more extensive changes to Julia itself, greatly reduce latency stemming from loading FixedPointNumbers. Ref JuliaLang/julia#35733. There will be very little benefit to this on its own, but we can at least find out if it works across Julia versions.
1 parent a290465 commit f0f9e74

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/FixedPointNumbers.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ rawtype(::Type{X}) where {T, X <: FixedPoint{T}} = T
4848
*(x::Real, ::Type{X}) where {X <: FixedPoint} = _convert(X, x)
4949

5050
# constructor-style conversions
51-
(::Type{X})(x::Real) where {X <: FixedPoint} = _convert(X, x)
51+
(::Type{X})(x::X) where {X <: FixedPoint} = x
52+
(::Type{X})(x::Number) where {X <: FixedPoint} = _convert(X, x)
5253

5354
function (::Type{<:FixedPoint})(x::AbstractChar)
5455
throw(ArgumentError("FixedPoint (Fixed or Normed) cannot be constructed from a Char"))
@@ -97,7 +98,6 @@ one(::Type{X}) where {X <: FixedPoint} = oneunit(X)
9798
inv_rawone(x) = (@generated) ? (y = 1.0 / rawone(x); :($y)) : 1.0 / rawone(x)
9899

99100
# traits
100-
sizeof(::Type{X}) where {X <: FixedPoint} = sizeof(rawtype(X))
101101
eps(::Type{X}) where {X <: FixedPoint} = X(oneunit(rawtype(X)), 0)
102102
typemax(::Type{T}) where {T <: FixedPoint} = T(typemax(rawtype(T)), 0)
103103
typemin(::Type{T}) where {T <: FixedPoint} = T(typemin(rawtype(T)), 0)

0 commit comments

Comments
 (0)