Skip to content

Conversation

@edenhaus
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings June 19, 2025 18:09
Copy link
Contributor

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

Optimizes the base64 decompression utilities by introducing a fast Zstandard detection path and improving LZMA header assembly.

  • Add ZSTD_MAGIC constant and is_zstd_compressed for quick Zstd checks
  • Refactor decompress_lzma to preallocate a single buffer instead of repeated Vec::insert calls
  • Update decompress_base64_data to 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 r is not descriptive; consider renaming it to something like xz_decoder or decoder for clarity.
    let mut r = XzDecoder::new_stream(source, stream);

src/util.rs:48

  • [nitpick] The decompress_zstd function lacks a doc comment; adding a brief explanation of its behavior would improve consistency with decompress_lzma.
fn decompress_zstd(bytes: &[u8]) -> Result<Vec<u8>, Box<dyn Error>> {

src/util.rs:15

  • Consider adding unit tests for is_zstd_compressed and 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());
Copy link

Copilot AI Jun 19, 2025

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.

Suggested change
return Err("Invalid 7z compressed data".into());
return Err("LZMA compressed data is too short to be valid (minimum length: 8 bytes)".into());

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.77%. Comparing base (d82619b) to head (299617b).
Report is 1 commits behind head on dev.

✅ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 19, 2025

CodSpeed Performance Report

Merging #1032 will not alter performance

Comparing optmize-util (299617b) with dev (d82619b)

Summary

✅ 6 untouched benchmarks

@edenhaus edenhaus added the pr: refactor PR with code refactoring label Jun 19, 2025
@edenhaus edenhaus merged commit 6b58c91 into dev Jun 19, 2025
27 checks passed
@edenhaus edenhaus deleted the optmize-util branch June 19, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: refactor PR with code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants