# std: Make the DEFLATE decompression routine 3x faster · gitcafe/zig

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

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

Visibility: public

Requested revision: 41f244bd2ff0a217a83a3d17fc82f4a773eca278

Requested commit: 41f244bd2ff0a217a83a3d17fc82f4a773eca278

Commit: 41f244bd2ff0a217a83a3d17fc82f4a773eca278

Tree: 729b595333edc06a8379f03215fd6cf424f7a627

Author: LemonBoy

Committer: LemonBoy

## Message

`````
std: Make the DEFLATE decompression routine 3x faster

A profiler run showed that the main bottleneck was the naive decoding of
the Huffman codes, replacing it with a nice trick borrowed by Zlib gave
a substantial speedup.
Replacing a `%` with a `and (mask-1)` gave another significant
improvement (yay for low hanging fruits).

A few numbers obtained by decompressing a 22M file:

Before:
```
./decompress  2,39s user 0,00s system 99% cpu 2,400 total
```

After:
```
./decompress  0,79s user 0,00s system 99% cpu 0,798 total
````

`````

## Parents

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

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