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

Commit 58dca93

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Minor optimization for fold/map of crefs.
- Don't traverse into scope crefs in the cref fold/map function in Expression, they won't contain any subscripts we want to traverse. Belonging to [master]: - #2497
1 parent 9d7f5d5 commit 58dca93

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Compiler/NFFrontEnd/NFExpression.mo

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public
6060
import NFComponent.Component;
6161
import NFClassTree.ClassTree;
6262
import NFClass.Class;
63+
import NFComponentRef.Origin;
6364

6465
record INTEGER
6566
Integer value;
@@ -1457,7 +1458,7 @@ public
14571458
list<Subscript> subs;
14581459
ComponentRef rest;
14591460

1460-
case ComponentRef.CREF()
1461+
case ComponentRef.CREF(origin = Origin.CREF)
14611462
algorithm
14621463
subs := list(mapSubscript(s, func) for s in cref.subscripts);
14631464
rest := mapCref(cref.restCref, func);
@@ -1635,7 +1636,7 @@ public
16351636
list<Subscript> subs;
16361637
ComponentRef rest;
16371638

1638-
case ComponentRef.CREF()
1639+
case ComponentRef.CREF(origin = Origin.CREF)
16391640
algorithm
16401641
subs := list(mapSubscriptShallow(s, func) for s in cref.subscripts);
16411642
rest := mapCref(cref.restCref, func);
@@ -1972,7 +1973,7 @@ public
19721973
end FoldFunc;
19731974
algorithm
19741975
() := match cref
1975-
case ComponentRef.CREF()
1976+
case ComponentRef.CREF(origin = Origin.CREF)
19761977
algorithm
19771978
arg := List.fold(cref.subscripts, function foldSubscript(func = func), arg);
19781979
arg := foldCref(cref.restCref, func, arg);
@@ -2193,7 +2194,7 @@ public
21932194
end ApplyFunc;
21942195
algorithm
21952196
() := match cref
2196-
case ComponentRef.CREF()
2197+
case ComponentRef.CREF(origin = Origin.CREF)
21972198
algorithm
21982199
for s in cref.subscripts loop
21992200
applyCrefSubscript(s, func);
@@ -2518,7 +2519,7 @@ public
25182519
list<Subscript> subs;
25192520
ComponentRef rest;
25202521

2521-
case ComponentRef.CREF()
2522+
case ComponentRef.CREF(origin = Origin.CREF)
25222523
algorithm
25232524
(subs, arg) := List.map1Fold(cref.subscripts, mapFoldSubscript, func, arg);
25242525
(rest, arg) := mapFoldCref(cref.restCref, func, arg);

0 commit comments

Comments
 (0)