Optimisation of unpackCString#

Don Stewart dons at galois.com
Tue Apr 29 14:44:00 EDT 2008


ndmitchell:
> Hi
> 
> >  > Cons: Makes the simplifier slightly more complex - but I hope not by much!
> >
> > And it doesn't work for my case -- I'd really want length as a compile
> >  time constant.
> >
> >  Could you elaborate on what kind of rules you think we could write with
> >  the ability to get the head?
> 
> One of my ideas was some RULES that expand:
> 
> test x | "neil" `isPrefixOf` x = ...
>           | "ned" `isPrefixOf` x = ...
> 
> And obtains direct pattern-matching code. I have a lazy
> continuation-based parsing library which could use this extensively.
> See my other ongoing thread on this mailing list for more details of
> where this is going.
> 
> >  The rule I'd like to write is:
> >
> >     "pack/packAddress" pack (unpackCString addr) = ByteString (length# xs) 0 addr
> 
> That requires Proposal 2, so needs to have an API defined -- including
> length# and some others. Out of curiosity, how much performance boost
> would this give in ByteString?

It matters for programs with lots of constant strings. HAppS' webserver
reported good speedups doing this translation by hand.

-- Don


More information about the Glasgow-haskell-users mailing list