Skip to content

V2 (extended flag)#293

Draft
BrianPugh wants to merge 109 commits intomainfrom
v2-develop-c2
Draft

V2 (extended flag)#293
BrianPugh wants to merge 109 commits intomainfrom
v2-develop-c2

Conversation

@BrianPugh
Copy link
Owner

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 53 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +266 to +273
index = self._bit_reader.read(self.window_bits)

string = self._window_buffer.get(index, match_size)

# Write up to end of buffer (no wrap)
remaining = self._window_buffer.size - self._window_buffer.pos
window_write = min(match_size, remaining)
self._window_buffer.write_bytes(string[:window_write])
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

Extended-match tokens are specified as “no wrap-around” (source must not cross the window boundary). The implementation currently uses _window_buffer.get(index, match_size), which wraps modulo the window size, so a malformed stream could silently read across the boundary instead of failing. Consider validating index + match_size <= window_size for extended matches and raising an error if it would wrap, aligning behavior with the C implementation’s bounds checks.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +43
print(f"{file_path.name}: {compressed_size:,} (**{ratio:.3f}**)")

avg = sum(ratios) / len(ratios)
print(f"Average Ratio: {avg}")
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

avg = sum(ratios) / len(ratios) will raise ZeroDivisionError if all files are empty/missing or otherwise skipped. Consider guarding for len(ratios) == 0 and exiting with a clearer message. Also, the per-file print includes Markdown formatting (**...**), which is surprising for a CLI script unless the output is intended to be pasted into Markdown.

Copilot uses AI. Check for mistakes.
Comment on lines +251 to +254
rle_count = self._bit_reader.read_huffman()
rle_count <<= _LEADING_RLE_HUFFMAN_BITS
rle_count += self._bit_reader.read(_LEADING_RLE_HUFFMAN_BITS)
rle_count += 1 + 1
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

In the extended RLE path, read_huffman() can return the _FLUSH sentinel on malformed/corrupted input, which would raise a TypeError when shifting/adding. Consider explicitly rejecting _FLUSH here (e.g., raise ValueError / EOFError) before doing bit operations, so invalid streams fail deterministically and with a clearer error.

Copilot uses AI. Check for mistakes.
Comment on lines +262 to +265
match_size = self._bit_reader.read_huffman()
match_size <<= _LEADING_EXTENDED_MATCH_HUFFMAN_BITS
match_size += self._bit_reader.read(_LEADING_EXTENDED_MATCH_HUFFMAN_BITS)
match_size += self.min_pattern_size + 11 + 1
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

In the extended-match path, the secondary read_huffman() used for the size payload can also return _FLUSH on malformed input, which would break the arithmetic and produce a confusing exception. Add an explicit check to disallow _FLUSH (and potentially validate the decoded size range) before computing match_size.

Copilot uses AI. Check for mistakes.
decompresses.append(viper_decompress)
Decompressors.append(NativeDecompressor)
decompresses.append(native_decompress)
except ImportError:
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
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.

1 participant