ByteString I/O Performance
simons at cryp.to
Tue Sep 4 15:35:49 EDT 2007
Duncan Coutts writes:
> We can't provide this interface as it modifies the immutable
> input ByteString.
Well, one could call it unsafeHGet. :-)
> [Mutable input buffer] really requires an api that guarantees
> that the buffer is no longer in use when the next chunk is
> read, destroying the previous content of the buffer.
I see your point. It would be nice if the API would guarantee
that the ByteString cannot be misused. Personally, I feel that is
a minor point though. When you read data into a buffer, then the
previous contents of that buffer is lost. That is hardly a
surprise and ByteString offers functions like 'copy' which allow
the user to design his algorithms correctly. Programmers who
don't want to face that problem can always use the hGet variant
that creates a new buffer every time.
Anyway, it's not a big thing. The modified hGet function is
simple enough so that those who want it can write it themselves.
Thank you for your time,
More information about the Libraries