-
Notifications
You must be signed in to change notification settings - Fork 146
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
Update Deflate.java #692
Update Deflate.java #692
Conversation
@@ -1309,7 +1309,7 @@ int longest_match(int cur_match) { | |||
&& window[++scan] == window[++match] && window[++scan] == window[++match] | |||
&& scan < strend); | |||
|
|||
len = MAX_MATCH - strend - scan; | |||
len = MAX_MATCH - (strend - scan); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here explaining that the parenthesis are required?
Otherwise someone may in the future believe they are unnecessary and remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem - I added a comment, based on my best understanding of the longest_match method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please run mvn formatter:format
so this comment is formatted correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In progress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you pull the third line of this comment up to the second line so that it doesn't appear to awkward?
I.e.
// len here is set to MAX_MATCH minus (strend minus scan, i.e. the distance between scan and
// strend) to ensure that best_len is set to the best possible length to lookahead
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be fine now, thanks!
Updates back to match the logic from jzlib's Deflate class to set len, minus jzlib's unnecessary cast to (int)
len = MAX_MATCH - (int)(strend - scan);
All tests are passing. I did not add a test to the codebase, but with a 105mb XML file, compression level 6
before this update:
after this update: