Skip to content

Commit

Permalink
- small optimizations
Browse files Browse the repository at this point in the history
- use memcpy instead of for loop
- do not copy the hashtable if not needed
  • Loading branch information
adrpo committed Nov 16, 2015
1 parent e0d2d02 commit 11653b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/InstExtends.mo
Expand Up @@ -1112,7 +1112,7 @@ algorithm

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

case (cache,env,SCode.CLASS_EXTENDS(name,mod,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed)),htParent)
equation
ht = BaseHashTable.copy(htParent);
ht = if listEmpty(elts) then htParent else BaseHashTable.copy(htParent);
(cache,mod) = fixModifications(cache,env,mod,ht);
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);
Expand Down
5 changes: 1 addition & 4 deletions SimulationRuntime/c/meta/meta_modelica_builtin.c
Expand Up @@ -605,10 +605,7 @@ modelica_metatype arrayCopy(modelica_metatype arr)
void* res = (struct mmc_struct*)mmc_mk_box_no_assign(nelts, MMC_ARRAY_TAG);
void **arrp = MMC_STRUCTDATA(arr);
void **resp = MMC_STRUCTDATA(res);
int i = 0;
for(i=0; i<nelts; i++) {
resp[i] = arrp[i];
}
memcpy(resp, arrp, sizeof(modelica_metatype)*nelts);
return res;
}

Expand Down

0 comments on commit 11653b5

Please sign in to comment.