Skip to content

Conversation

@Shane32
Copy link
Owner

@Shane32 Shane32 commented Oct 6, 2025

Cuts file size in half or so.

Summary by CodeRabbit

  • New Features

    • None
  • Refactor

    • Optimized QR code PDF export to reduce drawing operations and improve export/render performance, potentially producing smaller PDFs without changing visual output.
  • Documentation

    • Updated summary to describe the optimized PDF path generation approach.

@Shane32 Shane32 added this to the 1.7.0 milestone Oct 6, 2025
@Shane32 Shane32 self-assigned this Oct 6, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 6, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • QRCoderTests/TransposeVerificationTests.pdf_renderer.approved.pdf is excluded by !**/*.pdf

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Refactors PDF path generation in QRCoder/PdfByteQRCode.cs to replace per-module 1x1 rectangle emission with run-length encoding per row, batching contiguous dark modules into single rectangle commands via a while-based scan. No public API changes.

Changes

Cohort / File(s) Summary
PDF path generation (RLE consolidation)
QRCoder/PdfByteQRCode.cs
Replaced per-module 1x1 rectangles with run-length encoded rectangles per row in CreatePathFromModules; switched inner loop to a while-based scanner that skips light modules and emits a single startX y runLength 1 re command per contiguous dark run; updated comments; internal-only behavior change.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant PdfByteQRCode
  participant CreatePathFromModules as CreatePathFromModules()
  Caller->>PdfByteQRCode: Request PDF path for QR matrix
  PdfByteQRCode->>CreatePathFromModules: Build path from module matrix
  loop for each row y
    CreatePathFromModules->>CreatePathFromModules: Advance x while modules are light
    alt dark run found
      CreatePathFromModules->>CreatePathFromModules: Record startX and runLength
      CreatePathFromModules-->>PdfByteQRCode: Emit "startX y runLength 1 re"
    else no dark modules
      CreatePathFromModules-->>PdfByteQRCode: Continue to next row
    end
  end
  PdfByteQRCode-->>Caller: Return consolidated PDF path
  note over CreatePathFromModules: Replaced per-module rectangles with RLE per-row
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary improvement of the pull request, which replaces per-module rectangle generation in the PDF path algorithm with run-length encoding (RLE), and it accurately reflects the main change without extra noise or ambiguity.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Shane32 Shane32 requested a review from gfoidl October 6, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance related enhancements or benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants