
Hi Svein,
Hold on, he's using hGetBuf/hPutBuf.
exactly, that's what I was thinking. When a program requests that 'n' bytes ought to be read into memory at the location designated by the given 'Ptr Word8', how could GHC possibly do any encoding or decoding? That API doesn't allow for multi-byte characters. I would assume that hGetBuf/hPutBuf are the equivalent to POSIX read() and write()?
I wonder if the difference goes away if the handle is explicitly set to binary?
I added an
mapM_ (\h -> hSetBinaryMode h True) [ stdin, stdout ]
to 'main', and it does seem to improve performance a little, but it's
still quite a bit slower than /bin/cat:
| $ time /bin/cat