From 1484dbc5d4e84abfc1590792be4ad511ccf56174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 3 Feb 2020 17:25:55 +0100 Subject: [PATCH] [poincare] Multiplication::shallowReduce: simplify implementation! (recursivelyMatches all children is equivalent to recursivelyMatches on the current node) --- poincare/src/multiplication.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/poincare/src/multiplication.cpp b/poincare/src/multiplication.cpp index 44a2b1a75..b31f894f1 100644 --- a/poincare/src/multiplication.cpp +++ b/poincare/src/multiplication.cpp @@ -766,13 +766,7 @@ Expression Multiplication::privateShallowReduce(ExpressionNode::ReductionContext const Expression c = childAtIndex(0); if (c.type() == ExpressionNode::Type::Rational && static_cast(c).isZero()) { // Check that other children don't match inf or unit - bool infiniteOrUnitFactor = false; - for (int i = 1; i < numberOfChildren(); i++) { - infiniteOrUnitFactor = childAtIndex(i).recursivelyMatches([](const Expression e, Context * context) { return Expression::IsInfinity(e,context) || e.type() == ExpressionNode::Type::Unit; }, reductionContext.context()); - if (infiniteOrUnitFactor) { - break; - } - } + bool infiniteOrUnitFactor = recursivelyMatches([](const Expression e, Context * context) { return Expression::IsInfinity(e,context) || e.type() == ExpressionNode::Type::Unit; }, reductionContext.context()); if (!infiniteOrUnitFactor) { replaceWithInPlace(c); return c;