Improve zopfli encoder

Write in chunks for CLI compression
This commit is contained in:
topjohnwu
2021-11-23 16:50:08 -08:00
parent 449989ddd9
commit 048b2af0fc
3 changed files with 46 additions and 63 deletions

View File

@@ -50,8 +50,8 @@ public:
bool write(const void *buf, size_t len) final;
protected:
// Classes inheriting this class has to call close() in its destructor
void close();
// Classes inheriting this class has to call finalize() in its destructor
void finalize();
virtual bool write_chunk(const void *buf, size_t len) = 0;
size_t chunk_sz;

View File

@@ -140,7 +140,7 @@ bool chunk_out_stream::write(const void *_in, size_t len) {
return true;
}
void chunk_out_stream::close() {
void chunk_out_stream::finalize() {
if (buf_off) {
write_chunk(_buf, buf_off);
delete[] _buf;