quixdb / squash

Compression abstraction library and utilities
https://quixdb.github.io/squash/
MIT License
406 stars 53 forks source link

Add a way to reset a stream #157

Open nemequ opened 9 years ago

nemequ commented 9 years ago

zlib (at least, probably a couple others) are able to reset a stream without freeing and reallocating it, which can save a lot of time. It would probably require some changes to how we create streams in plugins, but it should be possible to expose this functionality in plugins which support it while emulating the feature (by freeing the old instance and creating a new one) for plugins which don't.

nemequ commented 9 years ago

I've created a wip/reset branch for this.

Everything is working except for the brotli plugin, which gets stuck not processing any data in the new "reset" test (no data is read or written by calls to squash_process). I think this may be an issue with the plugin outside of the changes required for making the stream resettable, since it sounds a lot like what is described at https://groups.google.com/forum/#!topic/squash-compression/hGNOqux2dlc

@eustas mentioned a plan to update the brotli plugin for Squash soon, I may just wait until then and see if that fixes the issue.