Comments (4)
I took a quick look, and it looks sane.
Maybe Compressor::new()
should pass failures to the caller rather than panicing, given that a NULL return from libdeflate_alloc_compressor()
can mean that the compression level is invalid? I.e. it doesn't always mean "out of memory".
Is the omission of bindings for the *_decompress_ex()
functions (which have the actual_in_nbytes_ret
argument) intentional? Likewise for the Adler32 and CRC-32 functions.
Also a few typos I happened to notice:
- panic message in
decompress_deflate()
has wrong function name - panic message in
Compressor::new()
has wrong function name - comment above
compress_zlib()
saysout_deflate_data
instead ofout_zlib_data
- comment above
compress_gzip()
saysout_deflate_data
instead ofout_gzip_data
from libdeflate.
Thanks for this @ebiggers , it is very valuable to have another dev look at this.
To deal with the fact that a NULL might be thrown by libdeflate_alloc_compressor()
because the compression level is invalid, I moved returning a result into CompressionLvl::new(i32)
, so the signature for that is now: pub fn new(level: i32) -> CompressionLevelResult
. This means that library users should not be able to construct an arbitrary CompressionLvl
without the number being range-checked.
I decided to add the Result
at this point, rather than in ::new
to make it clear, from a type-system POV, that the only thing a library user can do erroneously is provide an invalid compression level. Logically, there are no other side-effects to allocating a compressor other than memory allocation, and returning a Result
implies that there are either invalid function arguments or side-effects (e.g. IO) associated with allocation. The commit for that change is here:
adamkewley/libdeflater@75dae06
Amazingly well-spotted on the typos :D, which are now fixed:
adamkewley/libdeflater@b410db1
As for omitting the _decompress_ex()
and crc
functions, it is mostly because this is a first version that has the minimal API required that covers normal use-cases (e.g. loading a whole zlib blob). The _decompress_ex()
functions feel like they are targeted to more specific use-cases, such as loading a blob you "know" is chunked within some tolerance limit but where you don't know the exact chunk sizes up-front. I will add these methods the next time I get an hour or two to implement the wrappers (+ docs, tests, etc. etc.): again, I think they're useful but weren't the focus of this first version.
On another note, for the benchmarks, they're still not fully-formed yet because there's no comparison between the compression ratio of flate2's default compressors and libdeflate's default compression level, but the results do look promising for this particular corpus (I'll need "bad case" files, such as large files, for comparison)
from libdeflate.
Just as an update on this:
- I added the crc32 functions to the API (adamkewley/libdeflater@5b95efd)
- All methods have been renamed to match libdeflate (adamkewley/libdeflater@0d14ddb)
- Benchmarks have been updated with Canterbury corpus. Libdeflate is around ~2-3x faster on average (adamkewley/libdeflater@18c8278)
My intended next step for this is to throw the bindings out to the wider Rust community for more feedback. If it gains attention, then I'll also add the _ex
and adler32
functions as people ask for them. My main goal is to have a working first version of the bindings then adjust as things move forward!
from libdeflate.
Closing since I reviewed this earlier. Let me know if there's anything else you want me to take a look at or if you have any other questions.
from libdeflate.
Related Issues (20)
- v1.14 - v1.18 deflate compatibility HOT 5
- Decompressing Microsoft DOCX Files in Unreal Engine 5 with Libdeflate HOT 4
- Windows Explorer cannot unpack some files generated with libdeflate (reward offered) HOT 9
- Tests fail on Windows in Release mode with VS platform toolset v141 HOT 1
- Please also generate a static source code archive for release HOT 2
- Libdeflate compressed stream in kunzip fail to decompress HOT 12
- Slow level 0 "compression" HOT 2
- I added stream & multi-thread support for libdeflate HOT 16
- ESA matchfinder HOT 4
- crc32 is twice as fast in zlib-ng HOT 19
- how to change sliding window size at runtime? HOT 1
- arm_acle.h compiler errors when building for iOS with Xcode 15.3 HOT 4
- analyzer warning regression: The left operand of '+' is a garbage value due to array index out of bounds HOT 1
- Unaligned access on PowerPC: forgotten macros in `common_defs.h` HOT 11
- 32-bit build error when using cctools 949.0.1 with assembler that doesn't support AVX instructions HOT 7
- VNNI support seems to require something later than GCC 11.1 HOT 3
- error: inlining failed in call to 'always_inline' in some builds HOT 1
- BUILD: target specific option mismatch HOT 3
- 1.20 does not compile HOT 2
- compression & decompression usage from browser to libdeflate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libdeflate.