[commit: containers] master: Improve one of the benchmarked methods: lookupGE4. (ef61124)

Paolo Capriotti <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.libraries
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/packages/containers

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ef6112461bdbb5574d57da2bebcea75f3cfc5fe6

>---------------------------------------------------------------

commit ef6112461bdbb5574d57da2bebcea75f3cfc5fe6
Author: Milan Straka <[email protected]>
Date:   Mon Apr 23 18:29:50 2012 +0200

    Improve one of the benchmarked methods: lookupGE4.

>---------------------------------------------------------------

 benchmarks/LookupGE/LookupGE_IntMap.hs |   25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/benchmarks/LookupGE/LookupGE_IntMap.hs b/benchmarks/LookupGE/LookupGE_IntMap.hs
index 76fb705..4244339 100644
--- a/benchmarks/LookupGE/LookupGE_IntMap.hs
+++ b/benchmarks/LookupGE/LookupGE_IntMap.hs
@@ -53,27 +53,18 @@ lookupGE3 k t = k `seq` case t of
 
 lookupGE4 :: Key -> IntMap a -> Maybe (Key,a)
 lookupGE4 k t = k `seq` case t of
-    Bin _ m l r | m < 0 -> if k >= 0 then goNothing l
-                                     else goJust l r
-    _ -> goNothing t
+    Bin _ m l r | m < 0 -> if k >= 0 then go Nil l
+                                     else go l r
+    _ -> go Nil t
   where
-    goNothing (Bin p m l r)
-      | nomatch k p m = if k < p then fMin l else Nothing
-      | zero k m  = goJust r l
-      | otherwise = goNothing r
-    goNothing (Tip ky y)
-      | k > ky    = Nothing
-      | otherwise = Just (ky, y)
-    goNothing Nil  = Nothing
-
-    goJust def (Bin p m l r)
+    go def (Bin p m l r)
       | nomatch k p m = if k < p then fMin l else fMin def
-      | zero k m  = goJust r l
-      | otherwise = goJust def r
-    goJust def (Tip ky y)
+      | zero k m  = go r l
+      | otherwise = go def r
+    go def (Tip ky y)
       | k > ky    = fMin def
       | otherwise = Just (ky, y)
-    goJust def Nil  = fMin def
+    go def Nil  = fMin def
 
     fMin :: IntMap a -> Maybe (Key, a)
     fMin Nil = Nothing
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.