Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all libz-sys code with flate2 #173

Open
wants to merge 4 commits into
base: oxidize
Choose a base branch
from

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant