Frommi / miniz_oxide

Rust replacement for miniz
MIT License
168 stars 48 forks source link

dependency on the alloc crate should be optional. #111

Closed Lokathor closed 1 year ago

Lokathor commented 2 years ago

It seems like the core decompression routines can be performed without allocating at all.

We should make the use of the alloc crate optional behind a cargo feature, though this would be a breaking release to do so.

oyvindln commented 2 years ago

Yeah that seems reasonable.

mkeeter commented 2 years ago

I've implemented this in a with-alloc branch here:

Happy to open a PR, if you're willing to bring it in!

oyvindln commented 2 years ago

Yeah that looks good. I suspect this would be a breaking change that would require a version bump though?

Also gonna need some help to check that it works fine with rustc-dep-of-std but that's not critical yet (think that's still on an older version than the current one.)

mkeeter commented 2 years ago

Yeah, I wasn't totally sure about whether this would be breaking, and the docs didn't say anything about "adding a new feature and making it enabled by default".

I think it would only break in cases where people import the library with default-features = false. Doing so would be a no-op until this change, since there weren't any default features!

Anyways, I've bumped the version, added some docs, and opened a PR here.

Ironically, after testing it out, I'm probably not going to use it in my embedded system: it reduces a compressed object's size by 9.7K, but adds 11.5K of code to decompress it, for a slight net size increase 😅

dancrossnyc commented 1 year ago

Regardless of Matt's use case, I would love to see this integrated. :-)

oyvindln commented 1 year ago

yeah it's been merged in, just not in a release yet as I wanted to look at a few API tweaks for a version bumps.

dancrossnyc commented 1 year ago

yeah it's been merged in, just not in a release yet as I wanted to look at a few API tweaks for a version bumps.

Uh, I totally didn't miss that or anything. :-)

Thanks! I'm excited for the new release.

oyvindln commented 1 year ago

Released now, would probably be doable to do the same with compression later if there is interest.