[Haskell-cafe] Optimising UTF8-CString -> String marshaling, plus comments on withCStringLen/peekCStringLen

Bayley, Alistair Alistair_Bayley at invescoperpetual.co.uk
Mon Jul 23 06:43:52 EDT 2007

> From: haskell-cafe-bounces at haskell.org 
> [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Stefan O'Rear
> fromUTF8Ptr unboxes fine for me with HEAD and 6.6.1.
> > - the chr function tests that its Int argument is less than 1114111,
> >   before constructing the Char. It'd be nice to avoid this test.
> You want unsafeChr from the (undocumented) GHC.Base module.
> http://darcs.haskell.org/ghc-6.6/packages/base/GHC/Base.lhs for
> reference (but don't copy the file, it's already an 
> importable module).

> <odd duplicated simplifier output)
> ISTR seeing a bug report about this a while back, we know it's dumb.
> You could probably use x < 0xF8 instead.


I've optimised this to a point where I'm happy with it, and you can see
the results here:

I was using ghc-6.6 back in June, and an upgrade to 6.6.1 fixed some of
the issues for me (e.g. unboxing Ptrs, bang-patterns differ from seq).

I sent a test case to Simon PJ about the duplicated code in the
simplifier output, but I can't tell if it's been added as a trac ticket.

Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.

More information about the Haskell-Cafe mailing list