1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-08-13 02:28:59 +00:00

Optimize constants of form (B+A)-B

This commit is contained in:
Karol Stasiak 2018-08-07 17:36:14 +02:00
parent f937355c54
commit 7750c4ec45

View File

@ -263,6 +263,8 @@ case class CompoundConstant(operator: MathOperator.Value, lhs: Constant, rhs: Co
} else {
CompoundConstant(MathOperator.Minus, a, rr - ll).quickSimplify
}
case (CompoundConstant(MathOperator.Plus, a, ll@NumericConstant(lv, _)), b) if operator == MathOperator.Minus && a == b =>
ll.quickSimplify
case (CompoundConstant(MathOperator.Minus, a, ll@NumericConstant(lv, _)), rr@NumericConstant(rv, _)) if operator == MathOperator.Plus =>
if (lv >= rv) {
CompoundConstant(MathOperator.Minus, a, ll - rr).quickSimplify