From 407ce0534c97b63e201fa111f8fb09243d5cf82a Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Wed, 25 Mar 2020 14:41:41 +0100 Subject: [PATCH] [poincare/expression] Use extractUnits instead of hasUnit when possible --- poincare/src/expression.cpp | 2 +- poincare/src/power.cpp | 2 +- poincare/src/unit_convert.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 361af0cb4..40329a08e 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -350,7 +350,7 @@ Expression Expression::defaultHandleUnitsInChildren() { // Generically, an Expression does not accept any Unit in its children. const int childrenCount = numberOfChildren(); for (int i = 0; i < childrenCount; i++) { - if (childAtIndex(i).hasUnit()) { + if (!childAtIndex(i).extractUnits().isUninitialized()) { return replaceWithUndefinedInPlace(); } } diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 576820dc9..9d9ee0a62 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -392,7 +392,7 @@ Expression Power::shallowReduce(ExpressionNode::ReductionContext reductionContex // Step 1: Handle the units { - if (index.hasUnit()) { + if (!index.extractUnits().isUninitialized()) { // There must be no unit in the exponent return replaceWithUndefinedInPlace(); } diff --git a/poincare/src/unit_convert.cpp b/poincare/src/unit_convert.cpp index 8a448af0e..148897ef5 100644 --- a/poincare/src/unit_convert.cpp +++ b/poincare/src/unit_convert.cpp @@ -59,7 +59,7 @@ Expression UnitConvert::shallowReduce(ExpressionNode::ReductionContext reduction // Divide the left member by the new unit Expression division = Division::Builder(childAtIndex(0), finalUnit.clone()); division = division.reduce(reductionContext); - if (division.hasUnit()) { + if (!division.extractUnits().isUninitialized()) { // The left and right members are not homogeneous return replaceWithUndefinedInPlace(); }