ztellman/gloss — pull request #19 by geoffsalmon (2012-12-30 17:56:15+00:00)
Title: Unify Single/MultiBufferSequence behaviour: non-zero position and take-contiguous-bytes

Because MultiBufferSequence supports buffers with non-zero positions with take and drop bytes, it was surprising that SingleBufferSequence didn't. Another way to implement this would be to slice buffers with non-zero positions in create-buf-seq. The way I've done it here seems more symmetrical with MultiBufferSequence's implementation though.

Also take-contiguous-bytes was behaving differently for Single versus Multi BufferSequence when n was <= 0 or > byte-count. Not sure what behaviour you want. As implemented here, n <= 0 returns an empty buffer and n > byte-count returns all the bytes.

I erred on the side of not calling duplicate and assuming the caller won't muck with returned buffers, but maybe that isn't safe enough. There's a single empty-buffer that's allocated and returned from take-contiguous-bytes when appropriate. Should it be duplicated or allocated each time? SingleBufferSequence take-contiguous-bytes- returns buffer in n >= byte-count case. Should that be duplicated?