
On Mon, 2007-09-10 at 00:49 +0100, Neil Mitchell wrote:
Hi
(Some list operations are too expensive with ByteString but for most string processing it's perfectly fine and much faster than String).
I'm sure it's true, but it's quite irrelevant to my question, which is "why is using getChar so much slower than using getContents"?
Buffering, blocks and locks.
Buffering: getChar demands to get a character now, which pretty much means you can't buffer.
Blocks: getContents reads blocks at a time from the underlying library, whereas getChar has to do one character at a time.
Locks: getChar has to acquire locks, as does getContents. However, because getContents can operate on blocks, this requires many fewer locks.
A little more and that would have Dr. Seuss-esque.