I saw that the next major vibe.D release gets a new stream API, but the buffered API (currently only peek) is mostly unchanged. When writing streaming deserializers or looking at readUntil functions it always seemed like there's one main problem with the API: It's not possible to skip data without reading.

When searching for a delimiter in the peek buffer and not finding a delimiter we already know where valid data in the peek buffer is located. So the data can be easily extracted from the peek buffer. But in order to read further data, we still have to call read. This will then wastefully copy the data and we need an additional buffer for copy to read into. In the worst case, the internal peek buffer might not get refilled either if I remember correctly, so you'll have to read one byte again and hope that the buffer gets filled...

This API would seem much nicer with an additional advance(n) function which simply advances the internal buffer by n bytes and a fill(n) function which makes sure to fill the buffer with at least n bytes.

Has something like this been considered?

Johannes