Skip to content

Commit 3258410

Browse files
author
vruge
committed
make some traverseExpsOfExpList_WithStop tail recursive
1 parent 4492ef7 commit 3258410

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

Compiler/BackEnd/BackendEquation.mo

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,32 +1116,24 @@ protected function traverseExpsOfExpList_WithStop<T> "author Frenkel TUD
11161116
input list<DAE.Exp> inExpl;
11171117
input FuncExpType rel;
11181118
input T inExtArg;
1119-
output Boolean outBoolean;
1120-
output T outTypeA;
1119+
output Boolean outBoolean = true;
1120+
output T outTypeA = inExtArg;
11211121
partial function FuncExpType
11221122
input DAE.Exp inExp;
11231123
input T inTypeA;
11241124
output DAE.Exp outExp;
11251125
output Boolean cont;
11261126
output T outA;
11271127
end FuncExpType;algorithm
1128-
(outBoolean, outTypeA) := match(inExpl)
1129-
local
1130-
DAE.Exp e;
1131-
list<DAE.Exp> res;
1132-
T extArg;
1133-
Boolean b;
11341128

1135-
case {}
1136-
then (true, inExtArg);
11371129

1138-
case e::res equation
1139-
(_, b, extArg) = rel(e, inExtArg);
1140-
if b then
1141-
(b, extArg) = traverseExpsOfExpList_WithStop(res, rel, extArg);
1142-
end if;
1143-
then (b, extArg);
1144-
end match;
1130+
for e in inExpl loop
1131+
(_, outBoolean, outTypeA) := rel(e, outTypeA);
1132+
if not outBoolean then
1133+
break;
1134+
end if;
1135+
end for;
1136+
11451137
end traverseExpsOfExpList_WithStop;
11461138

11471139
public function traverseEquationArray<T> "author: Frenkel TUD

0 commit comments

Comments
 (0)