[commit: packages/containers] ghc-head: Change bitcount in IntSet to use popCount (de2214f)

git at git.haskell.org git at git.haskell.org
Fri Aug 30 13:33:58 CEST 2013


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

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/containers.git;a=commit;h=de2214f830d9f0c003ba35f2f352e831d5bea7f5

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

commit de2214f830d9f0c003ba35f2f352e831d5bea7f5
Author: Nicolas Trangez <ikke at nicolast.be>
Date:   Sat Sep 15 11:18:08 2012 +0200

    Change bitcount in IntSet to use popCount


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

de2214f830d9f0c003ba35f2f352e831d5bea7f5
 Data/IntSet/Base.hs |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Data/IntSet/Base.hs b/Data/IntSet/Base.hs
index 7e7c1a7..8df5911 100644
--- a/Data/IntSet/Base.hs
+++ b/Data/IntSet/Base.hs
@@ -1496,9 +1496,13 @@ 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
+#if MIN_VERSION_base(4,5,0)
+bitcount a x = a + popCount x
+#else
 bitcount a0 x0 = go a0 x0
   where go a 0 = a
         go a x = go (a + 1) (x .&. (x-1))
+#endif
 {-# INLINE bitcount #-}
 
 





More information about the ghc-commits mailing list