# flate change bit reader Bits to usize \(\#24719\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/6de23100352b9c94cc8c92737687091917951df3)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 6de23100352b9c94cc8c92737687091917951df3

Requested commit: 6de23100352b9c94cc8c92737687091917951df3

Commit: 6de23100352b9c94cc8c92737687091917951df3

Tree: be8e7a019f147e1e41db5846c7e91380e6d0bd9b

Author: Igor Anić

Committer: GitHub

## Message

```
flate change bit reader Bits to usize (#24719)

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.
```

## Parents

- [8843631f7ecfe0a7756a2f1f0bc99a24b57c2fcc](https://git.cafe/gitcafe/zig/commit/8843631f7ecfe0a7756a2f1f0bc99a24b57c2fcc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/6de23100352b9c94cc8c92737687091917951df3?format=markdown)
