Single-file decoder script can now (optionally) create an encoder#2065
Single-file decoder script can now (optionally) create an encoder#2065Cyan4973 merged 10 commits intofacebook:devfrom cwoffenden:single-file-lib
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.has-is and amalgamates the rest of the code (common,compressanddecompress). 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_Fmacro, probably moving it to the sharedfse.h(orerror_private.h).contribfolder 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.