bos/base64-bytestring — pull request #12 by andersk (2013-02-08 10:25:02+00:00)
Title: Lazy bytestring versions are insufficiently lazy

A redundant case in `reChunkIn` always forces one more input chunk to be evaluated than necessary to generate an output chunk.

Before fix:
``` haskell
> encode ("foofoofoofoofoofoofoo" <> "barbarbarbarbarbarbar" <> undefined)
"Zm9vZm9vZm9vZm9vZm9vZm9vZm9v*** Exception: Prelude.undefined
```

After fix:
``` haskell
> encode ("foofoofoofoofoofoofoo" <> "barbarbarbarbarbarbar" <> undefined)
"Zm9vZm9vZm9vZm9vZm9vZm9vZm9vYmFyYmFyYmFyYmFyYmFyYmFyYmFy*** Exception: Prelude.undefined
```

(Actually, we should be able to do even better: from the first 3q + r input bytes, we should be able to generate the first 4q + r output bytes, not just the first 4q. But that might require a bigger code reorganization.)