[commit: base] master: Worker/Wrapper and static argument transform for `until` so it can be inlined (9aa29b8)

Daniel Fischer <[email protected]> Thu, 06 Dec 2012 08:40:49 -0800
Newsgroups gmane.comp.lang.haskell.cvs.libraries
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/9aa29b806cb9e6c23adf6deb50a1bd14487487a4

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

commit 9aa29b806cb9e6c23adf6deb50a1bd14487487a4
Author: Daniel Fischer <[email protected]>
Date:   Thu Dec 6 16:38:12 2012 +0100

    Worker/Wrapper and static argument transform for `until` so it can be inlined
    
    With the direct top level recursion, `until` cannot be inlined by GHC, so no strictness
    analysis and consequently no unboxing occurs at the call site.
    With the recursion delegated to the worker with the condition and update function
    static arguments, it can be inlined, and strictness analysis can happen.

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

 GHC/Base.lhs |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/GHC/Base.lhs b/GHC/Base.lhs
index 303d716..075f21d 100644
--- a/GHC/Base.lhs
+++ b/GHC/Base.lhs
@@ -571,8 +571,10 @@ f $ x                   =  f x
 
 -- | @'until' p f@ yields the result of applying @f@ until @p@ holds.
 until                   :: (a -> Bool) -> (a -> a) -> a -> a
-until p f x | p x       =  x
-            | otherwise =  until p f (f x)
+until p f = go
+  where
+    go x | p x          = x
+         | otherwise    = go (f x)
 
 -- | 'asTypeOf' is a type-restricted version of 'const'.  It is usually
 -- used as an infix operator, and its typing forces its first argument