From 02355eb897dc9f1208748833dcae0ccdf704109d Mon Sep 17 00:00:00 2001 From: hkiel Date: Thu, 16 Nov 2017 13:57:00 +0100 Subject: [PATCH] use loop instead of recursive matchcontinue in BaseHashSet.get2 Belonging to [master]: - OpenModelica/OMCompiler#2026 --- Compiler/Util/BaseHashSet.mo | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Compiler/Util/BaseHashSet.mo b/Compiler/Util/BaseHashSet.mo index d7ad343a47f..7b1355d0ca5 100644 --- a/Compiler/Util/BaseHashSet.mo +++ b/Compiler/Util/BaseHashSet.mo @@ -350,26 +350,16 @@ protected function get2 input list> keyIndices; input FuncEq keyEqual; output Integer index; +protected + Key key2; algorithm - index := matchcontinue (key,keyIndices,keyEqual) - local - Key key2; - list> 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 ""