Faster IntSet by using BitMaps in the lower branches

Joachim Breitner mail at
Mon Sep 19 17:09:31 CEST 2011


Am Montag, den 19.09.2011, 16:03 +0200 schrieb Gregory Collins:
> On Sun, Sep 18, 2011 at 11:07 PM, Edward Kmett <ekmett at> wrote:
> > There are some neat tricks you can use using deBruijn multiplication to
> > optimize finding the least significant set bit.
> > My geometric coalgebra code
> > in
> > uses the following:
> I use this in hashtables also :)


-- only works with 32-bit values -- ok for us here
firstBitSet# :: Int# -> Int#

That’s why I feel uneasy about this method. But now we have already
three users of a firstBitSet function, all of which had to re-implement
the wheel. This is really a strong argument for putting this as a method
into Data.Bits and the code into GHC.Word, where machine-specific
instructions can be used if found to be faster.


Joachim "nomeata" Breitner
  mail at  |  nomeata at  |  GPG: 0x4743206C
  xmpp: nomeata at |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Libraries mailing list