Skip to content

Commit 3252674

Browse files
vrugeOpenModelica-Hudson
authored andcommitted
make equationList2 tail recursive
1 parent 3258410 commit 3252674

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Compiler/BackEnd/BackendEquation.mo

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ algorithm
135135
then {elt};
136136

137137
case (BackendDAE.EQUATION_ARRAY(numberOfElement=n, equOptArr=arr)) equation
138-
lst = equationList2(arr, n, {});
138+
lst = equationList2(arr, n);
139139
then lst;
140140

141141
case (_) equation
@@ -150,15 +150,9 @@ protected function equationList2 "author: PA
150150
outputs: BackendDAE.Equation list"
151151
input array<Option<BackendDAE.Equation>> arr;
152152
input Integer pos;
153-
input list<BackendDAE.Equation> iAcc;
154153
output list<BackendDAE.Equation> outEquationLst;
155154
algorithm
156-
outEquationLst := match (arr, pos, iAcc)
157-
case (_, 0, _)
158-
then iAcc;
159-
160-
else equationList2(arr, pos-1, List.consOption(arr[pos], iAcc));
161-
end match;
155+
outEquationLst := list(Util.getOption(arr[i]) for i guard isSome(arr[i]) in 1:pos);
162156
end equationList2;
163157

164158
public function getWhenEquationExpr "Get the left and right hand parts from an equation appearing in a when clause"

0 commit comments

Comments
 (0)