[commit: ghc] master: Make iterateFB inlineable (98ed815)

git at git.haskell.org git at git.haskell.org
Tue Oct 28 14:30:36 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/98ed815f658bdf9cc0299a4818244c3a56c20487/ghc

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

commit 98ed815f658bdf9cc0299a4818244c3a56c20487
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Tue Oct 28 15:28:59 2014 +0100

    Make iterateFB inlineable
    
    When investigating a case of unexpected Call Arity failure I noticed
    that iterateFB would not inline as far as desired, as it is recursive.
    
    This patch makes it non-recursive (with a local go), which seem so do
    great good.


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

98ed815f658bdf9cc0299a4818244c3a56c20487
 libraries/base/GHC/List.lhs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libraries/base/GHC/List.lhs b/libraries/base/GHC/List.lhs
index 2d01678..f993ee7 100644
--- a/libraries/base/GHC/List.lhs
+++ b/libraries/base/GHC/List.lhs
@@ -352,7 +352,8 @@ iterate f x =  x : iterate f (f x)
 
 {-# NOINLINE [0] iterateFB #-}
 iterateFB :: (a -> b -> b) -> (a -> a) -> a -> b
-iterateFB c f x = x `c` iterateFB c f (f x)
+iterateFB c f x0 = go x0
+  where go x = x `c` go (f x)
 
 {-# RULES
 "iterate"    [~1] forall f x.   iterate f x = build (\c _n -> iterateFB c f x)



More information about the ghc-commits mailing list