git.haskell.org
/
packages
/
containers.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
220be8c
)
Change bitcount in IntSet to use popCount
author
Nicolas Trangez
<ikke@nicolast.be>
Sat, 15 Sep 2012 09:18:08 +0000
(11:18 +0200)
committer
Nicolas Trangez
<ikke@nicolast.be>
Sat, 15 Sep 2012 09:18:08 +0000
(11:18 +0200)
Data/IntSet/Base.hs
patch
|
blob
|
history
diff --git
a/Data/IntSet/Base.hs
b/Data/IntSet/Base.hs
index
7e7c1a7
..
8df5911
100644
(file)
--- 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 #-}