image-rs / weezl

LZW en- and decoding that goes weeeee!
Apache License 2.0
25 stars 7 forks source link

A way to avoid huge allocations #10

Closed niklasf closed 3 years ago

niklasf commented 3 years ago

Currently the encoder unconditionally makes huge allocations. I assume this is a performance tradeoff.

https://github.com/image-rs/lzw/blob/0d3c809a37574cc84684e02c96c62ef079c926c9/src/encode.rs#L251

Could there be a way to select a different tradeoff, maximum, or maybe something based on the size of the input?

HeroicKatora commented 3 years ago

Hm, yes. I suppose you could add a method to configure this buffer size or to pass in a borrowed buffer with the lifetime of the state's borrow.

niklasf commented 3 years ago

Thank you! Amazing solution.