Fwd: [Haskell-cafe] Optimising UTF8-CString -> String marshaling, plus comments on withCStringLen/peekCStringLen
(this time include the list, too)
---------- Forwarded message ----------
From: Alistair Bayley
Are you sure fromUTF8Ptr is strict in its ptr arg? Try with a ! pattern on that arg. You'll need -fbang-patterns.
Is there some semantic advantage to bang-patterns, or is it just a syntactic convenience? 'cause once the guard is in there, it's not much bother to maintain.
You can also get ghc to tell you what strictness it inferred for your functions. It's shown in the .hi file. Use ghc --show-iface UTF8.hi.
I tried -ddump-hi and got: $wfromUTF8Ptr :: base:GHC.Prim.Int# -> base:GHC.Ptr.Ptr base:GHC.Word.Word8 -> base:GHC.Base.String -> base:GHC.Prim.State# base:GHC.Prim.RealWorld -> (# base:GHC.Prim.State# base:GHC.Prim.RealWorld, base:GHC.Base.String #) {- Arity: 4 Strictness: LSSL -} Assuming the LSSL tokens are in the same order as the function arguments, the first argument is lazy - GHC.Prim.Int#. hmmm.... some cognitive dissonance here. I'm a bit puzzled as to why it's in the .hi file at all - it's not an exported function. (I also see quite a bit of code in the hi-dump. Presumably this permits cross-module inlining, for those selected functions?) Alistair
participants (1)
-
Alistair Bayley