Currently the index is built:
- On calls to
zran_seek(n) - the index is bulit to cover up to position n in the uncompressed data
- On successive calls to
zran_read - when reading from position 0, one seek point is created at the beginning of the stream, but then no more points are created. If another call to zran_read is then made, the index is built to cover up to the position that the previous zran_read call finished - data is re-read and re-decompressed from the beginning of the file/stream. Then the read is initialised from that point.
This is complicated and inefficient - zran_seek should just update an internal offset into the uncompressed data, without doing anything else. Then zran_read should both read data and build the index in a single pass.
To support pre-generating an index, without reading any data, zran_read could allow buf to be NULL, which would cause it to read/build the index, but not copy any data.
Currently the index is built:
zran_seek(n)- the index is bulit to cover up to positionnin the uncompressed datazran_read- when reading from position 0, one seek point is created at the beginning of the stream, but then no more points are created. If another call tozran_readis then made, the index is built to cover up to the position that the previouszran_readcall finished - data is re-read and re-decompressed from the beginning of the file/stream. Then the read is initialised from that point.This is complicated and inefficient -
zran_seekshould just update an internal offset into the uncompressed data, without doing anything else. Thenzran_readshould both read data and build the index in a single pass.To support pre-generating an index, without reading any data,
zran_readcould allowbufto beNULL, which would cause it to read/build the index, but not copy any data.