DecoderBuffer: implement _skip() using decoder_skip()
This commit is contained in:
parent
b2b95cad20
commit
543a58bb87
@ -165,23 +165,14 @@ decoder_buffer_consume(DecoderBuffer *buffer, size_t nbytes)
|
|||||||
bool
|
bool
|
||||||
decoder_buffer_skip(DecoderBuffer *buffer, size_t nbytes)
|
decoder_buffer_skip(DecoderBuffer *buffer, size_t nbytes)
|
||||||
{
|
{
|
||||||
bool success;
|
const size_t available = decoder_buffer_available(buffer);
|
||||||
|
if (available >= nbytes) {
|
||||||
/* this could probably be optimized by seeking */
|
decoder_buffer_consume(buffer, nbytes);
|
||||||
|
return true;
|
||||||
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)
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user