Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 02355eb

Browse files
hkielOpenModelica-Hudson
authored andcommitted
use loop instead of recursive matchcontinue in BaseHashSet.get2
Belonging to [master]: - #2026
1 parent a6ecff6 commit 02355eb

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

Compiler/Util/BaseHashSet.mo

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -350,26 +350,16 @@ protected function get2
350350
input list<tuple<Key,Integer>> keyIndices;
351351
input FuncEq keyEqual;
352352
output Integer index;
353+
protected
354+
Key key2;
353355
algorithm
354-
index := matchcontinue (key,keyIndices,keyEqual)
355-
local
356-
Key key2;
357-
list<tuple<Key,Integer>> xs;
358-
359-
// search for the key, found the good one
360-
case (_,((key2,index) :: _),_)
361-
equation
362-
true = keyEqual(key, key2);
363-
then
364-
index;
365-
366-
// search more
367-
case (_,(_ :: xs),_)
368-
equation
369-
index = get2(key, xs, keyEqual);
370-
then
371-
index;
372-
end matchcontinue;
356+
for t in keyIndices loop
357+
(key2,index) := t;
358+
if keyEqual(key, key2) then
359+
return;
360+
end if;
361+
end for;
362+
fail();
373363
end get2;
374364

375365
public function printHashSet ""

0 commit comments

Comments
 (0)