mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/expression] Remove redundancies in getUnit
This commit is contained in:
committed by
Émilie Feral
parent
9a762f1bf6
commit
f2bfc7ec9b
@@ -256,12 +256,9 @@ int Multiplication::getPolynomialCoefficients(Context * context, const char * sy
|
||||
}
|
||||
|
||||
Expression Multiplication::getUnit() const {
|
||||
const int childrenCount = numberOfChildren();
|
||||
if (childrenCount == 1) {
|
||||
return childAtIndex(0).getUnit();
|
||||
}
|
||||
Multiplication result = Multiplication::Builder();
|
||||
int resultChildrenCount = 0;
|
||||
const int childrenCount = numberOfChildren();
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
Expression currentUnit = childAtIndex(i).getUnit();
|
||||
if (!currentUnit.isUninitialized()) {
|
||||
@@ -272,7 +269,7 @@ Expression Multiplication::getUnit() const {
|
||||
if (resultChildrenCount == 0) {
|
||||
return Expression();
|
||||
}
|
||||
return std::move(result);
|
||||
return result.squashUnaryHierarchyInPlace();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -986,9 +986,6 @@ Expression Power::shallowBeautify(ExpressionNode::ReductionContext reductionCont
|
||||
}
|
||||
|
||||
Expression Power::getUnit() const {
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Unit) {
|
||||
return clone();
|
||||
}
|
||||
Expression baseUnit = childAtIndex(0).getUnit();
|
||||
if (baseUnit.isUninitialized()) {
|
||||
return baseUnit;
|
||||
|
||||
Reference in New Issue
Block a user