Proposal: Add function to create new hash tables with a default size

Thomas Schilling nominolo at googlemail.com
Mon Jul 19 18:26:19 EDT 2010


On 15 July 2010 06:12, Jim Apple <jbapple+haskell-lib at gmail.com> wrote:
> In other some standard libraries (Java, OCaml), hash tables can be
> created with a user-supplied size. This avoids some resizing for users
> who know they will be inserting a lot of data.
>
> Data.HashTable does not expose a function to do this. This proposal
> changes that.
>
> For a dictionary of 5 million strings, this patch saves me about 33%
> of the total execution time. For 10 million strings, this patch saves
> me 50% of the total execution time.
>
> http://hackage.haskell.org/trac/ghc/ticket/4193

+1

Your round-up-to-next-power-of-2 code looks a bit weird and
complicated.  Why not use the standard bit-twiddling tricks?  (It's
not like it's polymorphic in Num.)
   http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2


More information about the Libraries mailing list