pfalcon / uzlib

Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Other
303 stars 82 forks source link

decomp: Switching from dest_size to dest_limit #19

Closed pfalcon closed 5 years ago

pfalcon commented 5 years ago

Since 50590fb5b64a13646c535ac8d89c2b3eae966155, there's asymmetry with how source vs dest end is handled: for source, it's source_limit, while for destination it's dest_size. For reference, https://github.com/pfalcon/uzlib/pull/10, which prompted addition of source_limit, also used "limit" concept for dest too, but it was found superfluous, duplicating existing dest_size checking.

However, I lean towards switching to dest_limit, because it simplifies dest progress tracking and checking: instead of dest++, dest_size--, it takes just dest++ (and < comparison for end test, yes). Currently, dest_size-- happens in one place, but that's because all decompression functions require to produce a single byte. That's obviously a bottleneck, and it would be nice to play with local optimizations of handling multiple bytes in some cases (while still single byte in others). That's where decrementing dest_size in multiple places becomes hairy, while "idempotent" comparison dest < dest_limit simplifies things.

pfalcon commented 5 years ago

Implemented in 3a578d0b7729ad52bdb44fadd7208760d7f9e6ed.