Skip to content

Commit

Permalink
use loop instead of recursive matchcontinue in BaseHashSet.get2
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2026
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Nov 16, 2017
1 parent a6ecff6 commit 02355eb
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions Compiler/Util/BaseHashSet.mo
Expand Up @@ -350,26 +350,16 @@ protected function get2
input list<tuple<Key,Integer>> keyIndices;
input FuncEq keyEqual;
output Integer index;
protected
Key key2;
algorithm
index := matchcontinue (key,keyIndices,keyEqual)
local
Key key2;
list<tuple<Key,Integer>> xs;

// search for the key, found the good one
case (_,((key2,index) :: _),_)
equation
true = keyEqual(key, key2);
then
index;

// search more
case (_,(_ :: xs),_)
equation
index = get2(key, xs, keyEqual);
then
index;
end matchcontinue;
for t in keyIndices loop
(key2,index) := t;
if keyEqual(key, key2) then
return;
end if;
end for;
fail();
end get2;

public function printHashSet ""
Expand Down

0 comments on commit 02355eb

Please sign in to comment.