Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Conversation

@cormacrelf
Copy link
Collaborator

@cormacrelf cormacrelf commented Oct 28, 2019

Much less prone to errors; reads directly into pdf_stream Vec<u8>.

Relevant: #171

@cormacrelf
Copy link
Collaborator Author

cormacrelf commented Oct 28, 2019

It's not the memLevel setting.

There appear to be three things responsible for the diffs:

  • The allocators! flate2 uses its own allocators, based on std::alloc. Swapping them in within a Rust version of compress2 gets different compression results.
  • flate2 also puts zlib headers in there by providing window_bits = -15 instead of 15.
  • flate2 also sets the flush value differently, to Z_NO_FLUSH where possible. This lets the algorithm control when to flush.

In any case, the PDFs all seem to open just fine. Zlib will always be able to decompress its own successful output.

[features]
default = ['libz-sys']
legacy-libz = ['libz-sys']
# to ensure binaries are not different, we link to libz-sys
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is inaccurate, I'm not sure there's really a backwards-compatibility point in keeping the zlib linking. I think the default backend runs about as quickly as zlib.

Copy link
Collaborator Author

@cormacrelf cormacrelf Oct 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With default, every file is different.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant