Skip to content

Commit

Permalink
Optimize EvaluateFunctions.getStatementLHSScalar
Browse files Browse the repository at this point in the history
- Don't append the input list recursively, to avoid exponential growth.

Belonging to [master]:
  - OpenModelica/OMCompiler#2723
  • Loading branch information
perost authored and OpenModelica-Hudson committed Oct 15, 2018
1 parent ca41844 commit bf49d96
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Compiler/BackEnd/EvaluateFunctions.mo
Expand Up @@ -2629,7 +2629,7 @@ algorithm
algs = List.filterOnTrue(elements,DAEUtil.isAlgorithm);
stmtLstLst = List.map(algs,DAEUtil.getStatement);
stmtLst1 = List.flatten(stmtLstLst);
expLst = List.fold1(stmtLst1,getStatementLHSScalar,funcTree,expsIn);
expLst = List.fold1(stmtLst1,getStatementLHSScalar,funcTree,{});
outputCrefs = List.map(expLst,Expression.expCref);

lhsCref = Expression.expCref(exp);
Expand All @@ -2638,18 +2638,21 @@ algorithm
outputCrefs = List.map1(outputCrefs,ComponentReference.joinCrefsR,lhsCref);

expLst = List.map(outputCrefs,Expression.crefExp);
expLst = listAppend(expLst,expsIn);
then
expLst;
listAppend(expLst,expsIn);

case(DAE.STMT_ASSIGN_ARR(lhs=exp),_,_)
equation
expLst = Expression.getComplexContents(exp);
expLst = listAppend(expLst,expsIn);
then expLst;
then
listAppend(expLst, expsIn);

else
equation
expLst = getStatementLHS(stmt,expsIn);
then expLst;
expLst = getStatementLHS(stmt,{});
then
listAppend(expLst, expsIn);

end matchcontinue;
end getStatementLHSScalar;

Expand Down

0 comments on commit bf49d96

Please sign in to comment.