Changeset e5d70b8c in OpenModelica for Compiler/BackEnd/BackendVarTransform.mo


Ignore:
Timestamp:
2016-04-01T12:36:21+02:00 (8 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
13e54206
Parents:
7eb2bd0
git-author:
Martin Sjölund <martin.sjolund@…> (04/01/16 12:36:21)
git-committer:
hudson <openmodelica@…> (04/01/16 12:36:21)
Message:

Remove redundant size Integer from HashTable

Also removed some unnecessary outputs (when we know that the HT is
updated mutable without changing the returned structure, etc).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Compiler/BackEnd/BackendVarTransform.mo

    rb6f2d8ba re5d70b8c  
    124124  input DAE.ComponentRef inSrc;
    125125  input Option<FuncTypeExp_ExpToBoolean> inFuncTypeExpExpToBooleanOption;
    126   output VariableReplacements outRepl;
    127126  partial function FuncTypeExp_ExpToBoolean
    128127    input DAE.Exp inExp;
    129128    output Boolean outBoolean;
    130129  end FuncTypeExp_ExpToBoolean;
    131 algorithm
    132   outRepl := matchcontinue (repl,inSrc,inFuncTypeExpExpToBooleanOption)
    133     local
    134       DAE.Exp dst;
    135       HashTable2.HashTable ht,ht_1,eht,eht_1;
    136       HashTable3.HashTable invHt,invHt_1;
    137       list<DAE.Ident> iv;
    138       String s;
    139       Option<HashTable2.HashTable> derConst;
    140     case (_,_,_)
    141       equation
    142         REPLACEMENTS(ht,_,_,_,_) = repl;
    143         false = BaseHashTable.hasKey(inSrc,ht);
    144       then
    145         repl;
    146     case (_,_,_)
    147       equation
    148         REPLACEMENTS(ht,invHt,eht,iv,derConst) = repl;
    149         dst = BaseHashTable.get(inSrc,ht);
    150         ht_1 = BaseHashTable.delete(inSrc,ht);
    151         _ = removeReplacementInv(invHt, inSrc, dst);
    152       then
    153         REPLACEMENTS(ht_1,invHt,eht,iv,derConst);
    154     case (_,_,_)
    155       equation
    156         s = ComponentReference.printComponentRefStr(inSrc);
    157         print("-BackendVarTransform.removeReplacement failed for " + s +"\n");
    158       then
    159         fail();
    160   end matchcontinue;
     130protected
     131  DAE.Exp dst;
     132  HashTable2.HashTable ht,ht_1,eht,eht_1;
     133  HashTable3.HashTable invHt,invHt_1;
     134  list<DAE.Ident> iv;
     135  String s;
     136  Option<HashTable2.HashTable> derConst;
     137algorithm
     138  REPLACEMENTS(ht,invHt,eht,iv,derConst) := repl;
     139  if not BaseHashTable.hasKey(inSrc,ht) then
     140    return;
     141  end if;
     142  try
     143    dst := BaseHashTable.get(inSrc,ht);
     144    BaseHashTable.delete(inSrc,ht);
     145    removeReplacementInv(invHt, dst);
     146  else
     147    Error.addInternalError("-BackendVarTransform.removeReplacement failed for " + ComponentReference.printComponentRefStr(inSrc) +"\n", sourceInfo());
     148  end try;
    161149end removeReplacement;
    162150
     
    165153  input list<DAE.ComponentRef> inSrcs;
    166154  input Option<FuncTypeExp_ExpToBoolean> inFuncTypeExpExpToBooleanOption;
    167   output VariableReplacements outRepl;
    168155  partial function FuncTypeExp_ExpToBoolean
    169156    input DAE.Exp inExp;
     
    171158  end FuncTypeExp_ExpToBoolean;
    172159algorithm
    173    outRepl := match(iRepl,inSrcs,inFuncTypeExpExpToBooleanOption)
    174      local
    175        DAE.ComponentRef cr;
    176        list<DAE.ComponentRef> crlst;
    177        VariableReplacements repl;
    178      case (_,{},_) then iRepl;
    179      case (_,cr::crlst,_)
    180        equation
    181          repl = removeReplacement(iRepl,cr,inFuncTypeExpExpToBooleanOption);
    182        then
    183          removeReplacements(repl,crlst,inFuncTypeExpExpToBooleanOption);
    184    end match;
     160  for cr in inSrcs loop
     161    removeReplacement(iRepl,cr,inFuncTypeExpExpToBooleanOption);
     162  end for;
    185163end removeReplacements;
    186164
     
    315293"
    316294  input HashTable3.HashTable invHt;
    317   input DAE.ComponentRef src;
    318295  input DAE.Exp dst;
    319   output HashTable3.HashTable outInvHt;
    320 algorithm
    321   outInvHt:=
    322   match (invHt,src,dst)
    323     local
    324       HashTable3.HashTable invHt_1;
    325       HashSet.HashSet set;
    326       list<DAE.ComponentRef> dests;
    327     case (_,_,_) equation
    328       // (_,set) = Expression.traverseExpTopDown(dst, traversingCrefFinder, HashSet.emptyHashSet() /* Very expensive operation */);
    329       // dests = BaseHashSet.hashSetList(set);
    330       dests = Expression.extractCrefsFromExp(dst);
    331       invHt_1 = List.fold(dests,BaseHashTable.delete,invHt);
    332       then
    333         invHt_1;
    334   end match;
     296algorithm
     297  for d in Expression.extractCrefsFromExp(dst) loop
     298    BaseHashTable.delete(d, invHt);
     299  end for;
    335300end removeReplacementInv;
    336301
Note: See TracChangeset for help on using the changeset viewer.