Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit bf49d96

Browse files
perostOpenModelica-Hudson
authored andcommitted
Optimize EvaluateFunctions.getStatementLHSScalar
- Don't append the input list recursively, to avoid exponential growth. Belonging to [master]: - #2723
1 parent ca41844 commit bf49d96

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Compiler/BackEnd/EvaluateFunctions.mo

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ algorithm
26292629
algs = List.filterOnTrue(elements,DAEUtil.isAlgorithm);
26302630
stmtLstLst = List.map(algs,DAEUtil.getStatement);
26312631
stmtLst1 = List.flatten(stmtLstLst);
2632-
expLst = List.fold1(stmtLst1,getStatementLHSScalar,funcTree,expsIn);
2632+
expLst = List.fold1(stmtLst1,getStatementLHSScalar,funcTree,{});
26332633
outputCrefs = List.map(expLst,Expression.expCref);
26342634

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

26402640
expLst = List.map(outputCrefs,Expression.crefExp);
2641-
expLst = listAppend(expLst,expsIn);
26422641
then
2643-
expLst;
2642+
listAppend(expLst,expsIn);
2643+
26442644
case(DAE.STMT_ASSIGN_ARR(lhs=exp),_,_)
26452645
equation
26462646
expLst = Expression.getComplexContents(exp);
2647-
expLst = listAppend(expLst,expsIn);
2648-
then expLst;
2647+
then
2648+
listAppend(expLst, expsIn);
2649+
26492650
else
26502651
equation
2651-
expLst = getStatementLHS(stmt,expsIn);
2652-
then expLst;
2652+
expLst = getStatementLHS(stmt,{});
2653+
then
2654+
listAppend(expLst, expsIn);
2655+
26532656
end matchcontinue;
26542657
end getStatementLHSScalar;
26552658

0 commit comments

Comments
 (0)