Skip to content

Commit

Permalink
remove redundant and wrpng nometa check
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed Mar 15, 2024
1 parent 4fc32c1 commit 037c25b
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,6 @@ function hasmetadata(s::Symbolic, ctx)
metadata(s) isa AbstractDict && haskey(metadata(s), ctx)
end

nometa(s) = isnothing(metadata(s))
nometa(ss...) = all(nometa, ss)

function issafecanon(f, s)
if isnothing(metadata(s)) || issym(s)
return true
Expand Down Expand Up @@ -1036,8 +1033,6 @@ sub_t(a) = promote_symtype(-, symtype(a))

import Base: (+), (-), (*), (//), (/), (\), (^)
function +(a::SN, b::SN)
!nometa(a,b) && return term(+, a, b) # Don't flatten if args have metadata

!issafecanon(+, a,b) && return term(+, a, b) # Don't flatten if args have metadata

if isadd(a) && isadd(b)
Expand All @@ -1055,8 +1050,6 @@ function +(a::SN, b::SN)
end

function +(a::Number, b::SN)
!nometa(b) && return term(+, a, b) # Don't flatten if args have metadata

!issafecanon(+, b) && return term(+, a, b) # Don't flatten if args have metadata

iszero(a) && return b
Expand All @@ -1072,17 +1065,13 @@ end
+(a::SN) = a

function -(a::SN)
!nometa(a) && return term(-, a)

!issafecanon(*, a) && return term(-, a)

isadd(a) ? Add(sub_t(a), -a.coeff, mapvalues((_,v) -> -v, a.dict)) :
Add(sub_t(a), makeadd(-1, 0, a)...)
end

function -(a::SN, b::SN)
!nometa(a, b) && return term(-, a, b)

(!issafecanon(+, a) || !issafecanon(*, b)) && return term(-, a, b)

isadd(a) && isadd(b) ? Add(sub_t(a,b),
Expand All @@ -1104,8 +1093,6 @@ mul_t(a) = promote_symtype(*, symtype(a))
function *(a::SN, b::SN)
# Always make sure Div wraps Mul

!nometa(a, b) && return term(*, a, b)

!issafecanon(*, a, b) && return term(*, a, b)

if isdiv(a) && isdiv(b)
Expand Down Expand Up @@ -1135,8 +1122,6 @@ end

function *(a::Number, b::SN)

!nometa(b) && return term(*, a, b)

!issafecanon(*, b) && return term(*, a, b)

if iszero(a)
Expand Down Expand Up @@ -1179,8 +1164,6 @@ end

function ^(a::SN, b)

!nometa(a,b) && return Pow(a, b)

!issafecanon(^, a,b) && return Pow(a, b)

if b isa Number && iszero(b)
Expand Down

0 comments on commit 037c25b

Please sign in to comment.