[base] Fix off-by-one error in writeBlocks

Niklas Haas haskell at nand.wakku.to
Sat Feb 22 18:36:25 UTC 2014


I've noticed an off-by-one issue in writeBlocks which writes a character
fewer than expected per block buffer in block buffering mode, when not
using CRLF mode (+ adding a newline).

I've implemented a patch which fixes this particular issue, but I
haven't eyeballed the Core or benchmarked it thoroughly to make sure
it's not a big performance regression.

The only concern I have, apart from performance, is that due to the way
the loop works we technically inspect the next cons cell *before*
actually flushing the buffer, so it's too strict by exactly one character.
I didn't know how to solve this without inverting the entire loop
though, and I'm very wary of the performance impact that would have.

I would appreciate feedback and comments. Is this issue worth pushing
the change in the first place?

Discussion period: 2 weeks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: text/x-diff
Size: 3658 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140222/70e1ae1d/attachment.diff>


More information about the Libraries mailing list