[poincare/expression] Use extractUnits instead of hasUnit when possible

This commit is contained in:
Ruben Dashyan
2020-03-25 14:41:41 +01:00
committed by Émilie Feral
parent f227cd719f
commit 407ce0534c
3 changed files with 3 additions and 3 deletions

View File

@@ -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();
}
}

View File

@@ -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();
}

View File

@@ -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();
}