Skip to content

Commit 11653b5

Browse files
committed
- small optimizations
- use memcpy instead of for loop - do not copy the hashtable if not needed
1 parent e0d2d02 commit 11653b5

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

Compiler/FrontEnd/InstExtends.mo

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

11131113
case (cache,env,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed),htParent)
11141114
equation
1115-
ht = BaseHashTable.copy(htParent);
1115+
ht = if listEmpty(elts) then htParent else BaseHashTable.copy(htParent);
11161116
ht = getLocalIdentList(elts,ht,getLocalIdentElement);
11171117
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
11181118
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);
@@ -1124,7 +1124,7 @@ algorithm
11241124

11251125
case (cache,env,SCode.CLASS_EXTENDS(name,mod,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed)),htParent)
11261126
equation
1127-
ht = BaseHashTable.copy(htParent);
1127+
ht = if listEmpty(elts) then htParent else BaseHashTable.copy(htParent);
11281128
(cache,mod) = fixModifications(cache,env,mod,ht);
11291129
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
11301130
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);

SimulationRuntime/c/meta/meta_modelica_builtin.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,7 @@ modelica_metatype arrayCopy(modelica_metatype arr)
605605
void* res = (struct mmc_struct*)mmc_mk_box_no_assign(nelts, MMC_ARRAY_TAG);
606606
void **arrp = MMC_STRUCTDATA(arr);
607607
void **resp = MMC_STRUCTDATA(res);
608-
int i = 0;
609-
for(i=0; i<nelts; i++) {
610-
resp[i] = arrp[i];
611-
}
608+
memcpy(resp, arrp, sizeof(modelica_metatype)*nelts);
612609
return res;
613610
}
614611

0 commit comments

Comments
 (0)