Skip to content

Commit 440c17b

Browse files
committed
Refactor -(::SN, ::SN) for easier debugging
1 parent 4a99619 commit 440c17b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/types.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,12 +1427,16 @@ function -(a::SN)
14271427
end
14281428

14291429
function -(a::SN, b::SN)
1430-
(!issafecanon(+, a) || !issafecanon(*, b)) && return term(-, a, b)
1431-
isadd(a) && isadd(b) ? Add(sub_t(a,b),
1432-
a.coeff - b.coeff,
1433-
_merge(-, a.dict,
1434-
b.dict,
1435-
filter=_iszero)) : a + (-b)
1430+
if !issafecanon(+, a) || !issafecanon(*, b)
1431+
return term(-, a, b)
1432+
elseif isadd(a) && isadd(b)
1433+
t = sub_t(a, b)
1434+
c = a.coeff - b.coeff
1435+
d = _merge(-, a.dict, b.dict, filter = _iszero)
1436+
return Add(t, c, d)
1437+
else
1438+
return a + (-b)
1439+
end
14361440
end
14371441

14381442
-(a::Number, b::SN) = a + (-b)

0 commit comments

Comments
 (0)