Commit 543a58bb authored by Max Kellermann's avatar Max Kellermann

DecoderBuffer: implement _skip() using decoder_skip()

parent b2b95cad
......@@ -165,23 +165,14 @@ decoder_buffer_consume(DecoderBuffer *buffer, size_t nbytes)
bool
decoder_buffer_skip(DecoderBuffer *buffer, size_t nbytes)
{
bool success;
/* this could probably be optimized by seeking */
while (true) {
auto data = decoder_buffer_read(buffer);
if (!data.IsEmpty()) {
if (data.size > nbytes)
data.size = nbytes;
decoder_buffer_consume(buffer, data.size);
nbytes -= data.size;
if (nbytes == 0)
const size_t available = decoder_buffer_available(buffer);
if (available >= nbytes) {
decoder_buffer_consume(buffer, nbytes);
return true;
}
success = decoder_buffer_fill(buffer);
if (!success)
return false;
}
decoder_buffer_clear(buffer);
nbytes -= available;
return decoder_skip(buffer->decoder, *buffer->is, nbytes);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment