Skip to content

Commit b3c3891

Browse files
committed
- Implemented BaseHashTable.copy and used it in InstExtends.fixClassdef, instead
of the previous slow way of building a new hashtable element by element. fixLocalIdents went from 40s to 15s for BatchPlant_StandardWater for me. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21270 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent a98159c commit b3c3891

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Compiler/FrontEnd/InstExtends.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ algorithm
11211121

11221122
case (cache,env,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed),htParent)
11231123
equation
1124-
ht = List.fold(BaseHashTable.hashTableList(htParent), BaseHashTable.add, HashTableStringToPath.emptyHashTable());
1124+
ht = BaseHashTable.copy(htParent);
11251125
ht = getLocalIdentList(elts,ht,getLocalIdentElement);
11261126
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
11271127
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);
@@ -1133,7 +1133,7 @@ algorithm
11331133

11341134
case (cache,env,SCode.CLASS_EXTENDS(name,mod,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed)),htParent)
11351135
equation
1136-
ht = List.fold(BaseHashTable.hashTableList(htParent), BaseHashTable.add, HashTableStringToPath.emptyHashTable());
1136+
ht = BaseHashTable.copy(htParent);
11371137
(cache,mod) = fixModifications(cache,env,mod,ht);
11381138
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
11391139
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);

Compiler/Util/BaseHashTable.mo

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,4 +636,20 @@ algorithm
636636
end match;
637637
end valueArrayNth;
638638

639+
public function copy
640+
"Makes a copy of a hashtable."
641+
input HashTable inHashTable;
642+
output HashTable outCopy;
643+
protected
644+
HashVector hv;
645+
Integer bs, sz, vs, ve;
646+
FuncsTuple ft;
647+
array<Option<HashEntry>> vae;
648+
algorithm
649+
(hv, (vs, ve, vae), bs, sz, ft) := inHashTable;
650+
hv := arrayCopy(hv);
651+
vae := arrayCopy(vae);
652+
outCopy := (hv, (vs, ve, vae), bs, sz, ft);
653+
end copy;
654+
639655
end BaseHashTable;

0 commit comments

Comments
 (0)