Repository : ssh://darcs.haskell.org//srv/darcs/packages/containers

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/34bdac9107e1dcc720be62723faa1b570b4eae4e

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

commit 34bdac9107e1dcc720be62723faa1b570b4eae4e
Author: Milan Straka <[email protected]>
Date:   Mon Nov 21 11:50:13 2011 +0100

    Improve performance of size.
    
    Inlining recursive bitcount leads to unnecessary heap allocation
    for every call to bitcount.
    
    When a bitcount just calls recursive function, heap allocation is
    avoided. (This is common issue of inlining recursive functions in GHC.)

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

 Data/IntSet.hs |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Data/IntSet.hs b/Data/IntSet.hs
index 28f8a68..61b7e84 100644
--- a/Data/IntSet.hs
+++ b/Data/IntSet.hs
@@ -1318,8 +1318,9 @@ foldr'Bits prefix f z bm = let lb = lowestBitSet bm
     Derrick Lehmer and published in 1964 in a book edited by Beckenbach.)"
 ----------------------------------------------------------------------}
 bitcount :: Int -> Word -> Int
-bitcount a 0 = a
-bitcount a x = bitcount (a + 1) (x .&. (x-1))
+bitcount a x = go a x
+  where go a 0 = a
+        go a x = go (a + 1) (x .&. (x-1))
 {-# INLINE bitcount #-}
 
 



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to