Skip to content

Commit 68b25c8

Browse files
committed
Remove convert methods which cause a large number of method invalidations.
These methods appear to be used from before we switched to MutableArithmetics. In the future, instead of overloading Base.convert, we should use a new function like `to_constant(::AffExpr)` which avoids the invalidation. Alternatively, future versions of Julia may be clever enough to avoid the invalidations.
1 parent e9b2bf3 commit 68b25c8

File tree

2 files changed

+0
-14
lines changed

2 files changed

+0
-14
lines changed

src/aff_expr.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ end
311311
function Base.convert(::Type{GenericAffExpr{T,V}}, v::_Constant) where {T,V}
312312
return GenericAffExpr{T,V}(convert(T, _constant_to_number(v)))
313313
end
314-
# Used in `JuMP._mul!`.
315-
function Base.convert(::Type{T}, aff::GenericAffExpr{T}) where T
316-
if !isempty(aff.terms)
317-
throw(InexactError(:convert, T, aff))
318-
end
319-
return convert(T, aff.constant)
320-
end
321314

322315
# Alias for (Float64, VariableRef), the specific GenericAffExpr used by JuMP
323316
const AffExpr = GenericAffExpr{Float64,VariableRef}

src/quad_expr.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,6 @@ function Base.convert(::Type{GenericQuadExpr{C, V}}, v::Union{_Constant,Abstract
324324
return GenericQuadExpr(convert(GenericAffExpr{C, V}, v))
325325
end
326326
GenericQuadExpr{C, V}() where {C, V} = zero(GenericQuadExpr{C, V})
327-
# Used in `JuMP._mul!`.
328-
function Base.convert(::Type{T}, quad::GenericQuadExpr{T}) where T
329-
if !isempty(quad.terms)
330-
throw(InexactError(:convert, T, quad))
331-
end
332-
return convert(T, quad.aff)
333-
end
334327

335328
function check_belongs_to_model(q::GenericQuadExpr, model::AbstractModel)
336329
check_belongs_to_model(q.aff, model)

0 commit comments

Comments
 (0)