-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single-file decoder script can now (optionally) create an encoder #2065
Conversation
To complement the single-file decoder a new script was added to create an amalgamated single-file of all of the Zstd source, along with examples and (simple) tests.
Thanks @cwoffenden for yet another great contribution ! I only have a few minor comments :
|
I'll tidy the two review points (probably) on Monday.
I think it's worth renaming, then I'll also add and document the choice of compressor, decompressor and both. |
`CHECK_F` macro moved to `error_private.h` (shared between `fse_compress.c` and `fse_decompress.c`). `ZSTD_limitCopy()` moved to `zstd_internal.h` (shared between `zstd_compress.c` and `zstd_decompress.c`). Erroneous build artefact `zstd.h` removed from repo.
`CHECK_F` is now in `error_private.h`. Minor tidy.
Directory renamed and suggestions implemented. |
Undefing XXH_* macros allows the `.c` to build standalone without clashes. Removing `xxhash.c` and only including the header is the correct usage (according to `XXH_PRIVATE_API`).
I think I'd call this finished for now. At some point I will:
|
Thanks @cwoffenden ! This is excellent. |
To complement the single-file decoder new scripts were added to create an amalgamated single-file of all the Zstd source, along with examples and (simple) tests.
Tested with Xcode/Clang, Visual Studio and Emscripten. Some notes and observations:
zstd.h
as-is and amalgamates the rest of the code (common
,compress
anddecompress
). It's possible to in-line this header file too but for a library it doesn't feel like the best approach.roundtrip.c
(compressing then decompressing data) is an amazing 237kB. This needs further investigation (DCE and LTO are probably doing their thing but it's worth a second look).As few changes as possible were made to the Zstd source. It's probably worth though:
CHECK_F
macro, probably moving it to the sharedfse.h
(orerror_private.h
).contrib
folder or renaming the decoder project. It's really easy to make single-file decoder, encoder and full codec now, so the instructions and demos could be expanded to show this.