Skip to content

Commit

Permalink
Avoid quadratic complexity in GzDecoder (rust-lang#278)
Browse files Browse the repository at this point in the history
* Avoid quadratic complexity in GzDecoder

Quadratic complexity happens when the underlying reader
supplies bytes one at a time and would block.
And if header flag FNAME is set and we never have a null
byte to end the filename, read_gz_header keeps reading
all of the partial filename and computing the CRC...

The solution is to keep a more complex structure than a
simple buffer for what has already been parsed in the
header (as is done in C zlib)

* fixup rustfmt

* fixup GzHeaderParsingState

* fixup read_once

* Revert "fixup read_once"

This reverts commit e463973.

* fixup using GzHeader in GzHeaderPartial

* Fixup read_gz_header_part used by read_gz_header

* fixup read_once and add test about it

* fixup moce crc to GzHeaderPartial

* dummy lifetime

* It works
  • Loading branch information
catenacyber authored Aug 27, 2021
1 parent 33f9f3d commit 7212da8
Showing 1 changed file with 352 additions and 98 deletions.
Loading

0 comments on commit 7212da8

Please sign in to comment.