Adding manual worker/wrapper transforms to Data.Map

Johan Tibell johan.tibell at gmail.com
Fri Aug 20 04:36:02 EDT 2010


On Thu, Aug 19, 2010 at 6:52 PM, Ian Lynagh <igloo at earth.li> wrote:

> On Thu, Aug 19, 2010 at 11:38:10AM +0200, Johan Tibell wrote:
> >
> > I tried doing the "standard" worker/wrapper transform to some functions
> in
> > Data.Map. For example, by transforming
> >
> >     insertWithKey' f kx x t0
> >       = case t of
> >
> > to
> >
> >     insertWithKey' f kx x t0 = kx `seq` go t0
> >       where
> >         go t = case t of
> >
> > I got a 16% speedup on this benchmark:
>
> Looks like as well as W/W you've also made it strict in the key, so this
> speedup isn't all W/W.
>

Right. Like Milan did in his work on containers I made the function key
strict. This doesn't really make a difference in practice as far as
semantics go as the function is already key strict iff the map isn't empty.
I'll make a libraries proposal with the code changes so people can decide if
this is something we want.

Note: Most of the speedup comes from W/W though.

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20100820/8f60968a/attachment.html


More information about the Libraries mailing list