Permalink
Browse files

Change bitcount in IntSet to use popCount

  • Loading branch information...
1 parent 220be8c commit de2214f830d9f0c003ba35f2f352e831d5bea7f5 @NicolasT NicolasT committed Sep 15, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 Data/IntSet/Base.hs
View
4 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 #-}

0 comments on commit de2214f

Please sign in to comment.