-
-
Notifications
You must be signed in to change notification settings - Fork 144
Optimize rust util #1032
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
Optimize rust util #1032
Conversation
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.
Pull Request Overview
Optimizes the base64 decompression utilities by introducing a fast Zstandard detection path and improving LZMA header assembly.
- Add
ZSTD_MAGICconstant andis_zstd_compressedfor quick Zstd checks - Refactor
decompress_lzmato preallocate a single buffer instead of repeatedVec::insertcalls - Update
decompress_base64_datato dispatch to Zstd or LZMA based on the magic bytes
Comments suppressed due to low confidence (3)
src/util.rs:42
- [nitpick] The variable name
ris not descriptive; consider renaming it to something likexz_decoderordecoderfor clarity.
let mut r = XzDecoder::new_stream(source, stream);
src/util.rs:48
- [nitpick] The
decompress_zstdfunction lacks a doc comment; adding a brief explanation of its behavior would improve consistency withdecompress_lzma.
fn decompress_zstd(bytes: &[u8]) -> Result<Vec<u8>, Box<dyn Error>> {
src/util.rs:15
- Consider adding unit tests for
is_zstd_compressedand the zstd decompression path to ensure correct detection and handling of Zstandard-compressed data.
fn is_zstd_compressed(bytes: &[u8]) -> bool {
| /// Decompress LZMA data, avoiding Vec insert overhead. | ||
| fn decompress_lzma(bytes: &[u8]) -> Result<Vec<u8>, Box<dyn Error>> { | ||
| if bytes.len() < 8 { | ||
| return Err("Invalid 7z compressed data".into()); |
Copilot
AI
Jun 19, 2025
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.
The error message "Invalid 7z compressed data" is vague and references 7z, which may be confusing; consider clarifying the failure condition or using a more descriptive/custom error type.
| return Err("Invalid 7z compressed data".into()); | |
| return Err("LZMA compressed data is too short to be valid (minimum length: 8 bytes)".into()); |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## dev #1032 +/- ##
=======================================
Coverage 93.77% 93.77%
=======================================
Files 129 129
Lines 5012 5014 +2
Branches 327 327
=======================================
+ Hits 4700 4702 +2
Misses 249 249
Partials 63 63 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #1032 will not alter performanceComparing Summary
|
No description provided.