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

Optimise distance length 258 edge case #3

Open
2 tasks
NeRdTheNed opened this issue Oct 8, 2023 · 2 comments
Open
2 tasks

Optimise distance length 258 edge case #3

NeRdTheNed opened this issue Oct 8, 2023 · 2 comments

Comments

@NeRdTheNed
Copy link
Owner

Distance codes with a length of 258 are usually encoded with code 285. However, it's technically possible to encode these with code 284, as a length of 227 (base length) + 31 (extra bits). This may not be legal according to the Deflate specification, and it's not considered good practice (Mark Adler has stated "In any case, a self-respecting deflate compressor should never produce [this code]."). deft4j currently misses two optimisations related to this:

  • Trying to replace code 285 with code 284 if it saves space (possibly not spec legal)
  • Trying to replace code 284 (with a length of 258) with code 285 if it saves space (spec legal)

See #1 for previous discussion.

@ace-dent
Copy link

ace-dent commented Oct 8, 2023

Perhaps add the parameter switch -cautious (vs -reckless!) to cover this stricter conformance and for #2 ?

@NeRdTheNed
Copy link
Owner Author

Perhaps add the parameter switch -cautious (vs -reckless!) to cover this stricter conformance and for #2 ?

I think options like that would be a good idea. I might keep these two optimisations behind seperate switches, because issues related to #2 are from decoders which can't decode certain valid deflate streams, while issues related to this would be from creating possibly standard non-compliant streams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants