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

Update Deflate.java #692

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/com/jcraft/jsch/jzlib/Deflate.java
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,9 @@ int longest_match(int cur_match) {
&& window[++scan] == window[++match] && window[++scan] == window[++match]
&& scan < strend);

len = MAX_MATCH - strend - scan;
// 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
len = MAX_MATCH - (strend - scan);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In progress.

Copy link
Contributor

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

scan = strend - MAX_MATCH;

if (len > best_len) {
Expand Down