Skip to content

Commit b6f2d8b

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Change set representation for BackendVarTransform
Most expressions contain few crefs (0~2), so we use a list for a set representation. The HashSet datatype typically allocates 4k elements just to remove duplicates in this set of 0~2 variables.
1 parent cbd4fc8 commit b6f2d8b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Compiler/BackEnd/BackendVarTransform.mo

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,9 @@ algorithm
325325
HashSet.HashSet set;
326326
list<DAE.ComponentRef> dests;
327327
case (_,_,_) equation
328-
(_,set) = Expression.traverseExpTopDown(dst, traversingCrefFinder, HashSet.emptyHashSet());
329-
dests = BaseHashSet.hashSetList(set);
328+
// (_,set) = Expression.traverseExpTopDown(dst, traversingCrefFinder, HashSet.emptyHashSet() /* Very expensive operation */);
329+
// dests = BaseHashSet.hashSetList(set);
330+
dests = Expression.extractCrefsFromExp(dst);
330331
invHt_1 = List.fold(dests,BaseHashTable.delete,invHt);
331332
then
332333
invHt_1;
@@ -350,8 +351,9 @@ algorithm
350351
HashSet.HashSet set;
351352
list<DAE.ComponentRef> dests;
352353
case (_,_,_) equation
353-
(_,set) = Expression.traverseExpTopDown(dst, traversingCrefFinder, HashSet.emptyHashSet());
354-
dests = BaseHashSet.hashSetList(set);
354+
// (_,set) = Expression.traverseExpTopDown(dst, traversingCrefFinder, HashSet.emptyHashSet() /* Very expensive operation */);
355+
// dests = BaseHashSet.hashSetList(set);
356+
dests = Expression.extractCrefsFromExp(dst);
355357
invHt_1 = List.fold1r(dests,addReplacementInv2,src,invHt);
356358
then
357359
invHt_1;

0 commit comments

Comments
 (0)