aboutsummaryrefslogtreecommitdiff
path: root/lib/std/compress/flate
AgeCommit message (Collapse)Author
2025-09-30add deflate compression, simplify decompressionKendall Condon
Implements deflate compression from scratch. A history window is kept in the writer's buffer for matching and a chained hash table is used to find matches. Tokens are accumulated until a threshold is reached and then outputted as a block. Flush is used to indicate end of stream. Additionally, two other deflate writers are provided: * `Raw` writes only in store blocks (the uncompressed bytes). It utilizes data vectors to efficiently send block headers and data. * `Huffman` only performs Huffman compression on data and no matching. The above are also able to take advantage of writer semantics since they do not need to keep a history. Literal and distance code parameters in `token` have also been reworked. Their parameters are now derived mathematically, however the more expensive ones are still obtained through a lookup table (expect on ReleaseSmall). Decompression bit reading has been greatly simplified, taking advantage of the ability to peek on the underlying reader. Additionally, a few bugs with limit handling have been fixed.
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-15std.compress.zstd.Decompress fixesAndrew Kelley
* std.Io.Reader: appendRemaining no longer supports alignment and has different rules about how exceeding limit. Fixed bug where it would return success instead of error.StreamTooLong like it was supposed to. * std.Io.Reader: simplify appendRemaining and appendRemainingUnlimited to be implemented based on std.Io.Writer.Allocating * std.Io.Writer: introduce unreachableRebase * std.Io.Writer: remove minimum_unused_capacity from Allocating. maybe that flexibility could have been handy, but let's see if anyone actually needs it. The field is redundant with the superlinear growth of ArrayList capacity. * std.Io.Writer: growingRebase also ensures total capacity on the preserve parameter, making it no longer necessary to do ensureTotalCapacity at the usage site of decompression streams. * std.compress.flate.Decompress: fix rebase not taking into account seek * std.compress.zstd.Decompress: split into "direct" and "indirect" usage patterns depending on whether a buffer is provided to init, matching how flate works. Remove some overzealous asserts that prevented buffer expansion from within rebase implementation. * std.zig: fix readSourceFileToAlloc returning an overaligned slice which was difficult to free correctly. fixes #24608
2025-08-14std.Io.Writer: introduce rebase to the vtableAndrew Kelley
fixes #24814
2025-08-13std.io.Writer.Allocating: rename getWritten() to written()Isaac Freund
This "get" is useless noise and was copied from FixedBufferWriter. Since this API has not yet landed in a release, now is a good time to make the breaking change to fix this.
2025-08-08std.Io.Writer.Allocating: configurable bump amountAndrew Kelley
2025-08-08std.compress.flate.Decompress: fix buffer size in testAndrew Kelley
2025-08-08flate: Handle invalid block typeRyan Liptak
Fixes `panic: invalid enum value` when the type bits had the u2 value of 3. Contributes towards #24741
2025-08-07flate change bit reader Bits to usize (#24719)Igor Anić
Don't see why byte returned from specialPeek needs to be shifted by remaining_needed_bits. I believe that decision in specialPeek should be done on the number of the remaining bits not of the content of that bits. Some test result are changed, but they are now consistent with the original state as found in: https://github.com/ziglang/zig/blame/5f790464b0d5da3c4c1a7252643e7cdd4c4b605e/lib/std/compress/flate/Decompress.zig Changing Bits from usize to u32 or u64 now returns same results. * flate: simplify peekBitsEnding `peekBits` returns at most asked number of bits. Fails with EndOfStream when there are no available bits. If there are less bits available than asked still returns that available bits. Hopefully this change better reflects intention. On first input stream peek error we break the loop.
2025-08-05flate zlib fix end of block readingIgor Anić
`n` is wanted number of bits to toss `buffered_n` is actual number of bytes in `next_int`
2025-08-04std.compress.flate.Decompress: return correct size for unbuffered decompressionIan Johnson
Closes #24686 As a bonus, this commit also makes the `git.zig` "testing `main`" compile again.
2025-08-01std.compress.flate.Decompress: use 64 buffered bitsAndrew Kelley
will have to find out why usize doesn't work for 32 bit targets some other time
2025-07-31std.compress.flate.Decompress: respect stream limitAndrew Kelley
2025-07-31std.compress.flate.Decompress: be in indirect or direct modeAndrew Kelley
depending on whether buffered
2025-07-31std.compress.flate.Decompress: allow users to swap out WriterAndrew Kelley
2025-07-31std.compress: fix discard impl and flate error detectionAndrew Kelley
2025-07-31std: match readVec fn prototype exactlyAndrew Kelley
this is not necessary according to zig language, but works around a flaw in the C backend
2025-07-31fix test failures by adding readVecAndrew Kelley
2025-07-31std.compress.flate.Decompress: implement readVec and discardAndrew Kelley
2025-07-31fix 32-bit compilationAndrew Kelley
2025-07-31std.compress.flate.Decompress: delete bad unit testsAndrew Kelley
if I remove the last input byte from "don't read past deflate stream's end" (on master branch), the test fails with error.EndOfStream. what, then, is it supposed to be testing?
2025-07-31std.compress.flate.Decompress: hashing is out of scopeAndrew Kelley
This API provides the data; applications can verify their own checksums.
2025-07-31putting stuff back does not require mutationAndrew Kelley
2025-07-31compiler: update to new flate APIAndrew Kelley
2025-07-31simplify tossBitsEndingAndrew Kelley
2025-07-31fix takeBitsEndingAndrew Kelley
2025-07-31make takeBits deal with integers onlyAndrew Kelley
2025-07-31fix peekBitsEndingAndrew Kelley
2025-07-31error.EndOfStream disambiguationAndrew Kelley
2025-07-31implement tossBitsEndingAndrew Kelley
2025-07-31std.compress.flate.Decompress: unfuck the test suiteAndrew Kelley
2025-07-31simplify test casesAndrew Kelley
2025-07-31std.compress.flate.Decompress: don't compute checksumsAndrew Kelley
These have no business being in-bound; simply provide the expected values to user code for maximum flexibility.
2025-07-31refactor gzip test casesAndrew Kelley
zig newbies love using for loops in unit tests
2025-07-31std.compress.flate.Decompress: implement peekBitsEnding and writeMatchAndrew Kelley
2025-07-31fix bit read not at eofAndrew Kelley
2025-07-31std.compress.flate.Decompress: fix bit read at eofAndrew Kelley
2025-07-31std.compress.flate.Decompress: implement more bit readingAndrew Kelley
2025-07-31std.compress.flate.Decompress: passing basic test caseAndrew Kelley
2025-07-31std.compress.flate.Decompress: add rebase implAndrew Kelley
2025-07-31std.Io: remove BitWriterAndrew Kelley
2025-07-31std.compress.flate: finish reorganizingAndrew Kelley
2025-07-31delete flate implementationAndrew Kelley
2025-07-31std.compress: rework flate to new I/O APIAndrew Kelley
2025-07-07std.io: deprecated Reader/Writer; introduce new APIAndrew Kelley
2025-01-22std.compress.flate.Lookup: Replace invisible doc comments with top-level doc ↵Shun Sakai
comments I think it would be better if this invisible doc comments is top-level doc comments rather than doc comments. Because it is at the start of a source file. This makes the doc comments visible.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-09std: fix typos (#20560)Jora Troosh
2024-05-09std.compress.flate: fix panic when reading into empty bufferPavel Verigo
2024-03-04zlib: fix missing comptime attributeIgor Anić