mirror of
https://github.com/KarolS/millfork.git
synced 2025-03-24 10:33:53 +00:00
Optimize constants of form (B+A)-B
This commit is contained in:
parent
f937355c54
commit
7750c4ec45
2
src/main/scala/millfork/env/Constant.scala
vendored
2
src/main/scala/millfork/env/Constant.scala
vendored
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user