[poincare/symbol_abstract] No need to clone the expression for a Function

Already cloned in the global context.
This commit is contained in:
Ruben Dashyan
2019-09-25 10:14:30 +02:00
committed by Léa Saviot
parent fc392d4e81
commit b728fb8a1b
2 changed files with 2 additions and 5 deletions

View File

@@ -125,7 +125,7 @@ Expression Function::shallowReduce(ExpressionNode::ReductionContext reductionCon
}
Expression Function::deepReplaceReplaceableSymbols(Context * context, bool * didReplace) {
Expression e = context->expressionForSymbolAbstract(*this, true);
Expression e = context->expressionForSymbolAbstract(*this, false);
if (e.isUninitialized()) {
return *this;
}

View File

@@ -57,10 +57,7 @@ bool SymbolAbstract::matches(const SymbolAbstract & symbol, ExpressionTest test,
}
Expression SymbolAbstract::Expand(const SymbolAbstract & symbol, Context * context, bool clone) {
bool isFunction = symbol.type() == ExpressionNode::Type::Function;
/* Always clone the expression for Function because we are going to alter e
* by replacing all UnknownX in it. */
Expression e = context->expressionForSymbolAbstract(symbol, clone || isFunction);
Expression e = context->expressionForSymbolAbstract(symbol, clone);
/* Replace all the symbols iteratively. This prevents a memory failure when
* symbols are defined circularly. */
e = Expression::ExpressionWithoutSymbols(e, context);