Skip to content

Conversation

@Shane32
Copy link
Owner

@Shane32 Shane32 commented Oct 1, 2025

Summary by CodeRabbit

  • Refactor
    • Optimized numeric QR encoding to reduce allocations and improve speed on newer runtimes by using more efficient parsing for fixed-width digit groups.
    • Enhances performance when generating QR codes with numeric content, especially for large inputs, while preserving identical output and compatibility across supported platforms.

@Shane32 Shane32 self-assigned this Oct 1, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

📝 Walkthrough

Walkthrough

Replaced conditional compilation symbol NET5_0_OR_GREATER with NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1 in QRCodeGenerator.PlainTextToBinaryNumeric, switching numeric parsing from Substring to AsSpan for fixed-width digit groups (3-digit groups, 2-digit remainder, 1-digit remainder). No public API changes.

Changes

Cohort / File(s) Summary
Numeric parsing path updates
QRCoder/QRCodeGenerator.cs
Updated preprocessor conditions to `NETCOREAPP2_1_OR_GREATER

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 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 “Fix #if conditional to match rest of application” directly captures the core change of updating the conditional compilation symbols to align with existing patterns in the codebase. It succinctly describes the main purpose of the PR without unnecessary detail, making it clear to reviewers that the change is focused on correcting the #if directives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_if

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 446aa0c and ca0dce5.

📒 Files selected for processing (1)
  • QRCoder/QRCodeGenerator.cs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
QRCoder/QRCodeGenerator.cs (3)

1012-1016: LGTM! Conditional directive now matches the codebase pattern.

The change from NET5_0_OR_GREATER to NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1 aligns with the file-level conditional at line 2 and enables span-based optimization on a broader set of target frameworks where AsSpan is available.


1024-1028: LGTM! Consistent conditional directive.

The change correctly applies the same framework conditional as the rest of the file for the 2-digit remainder case.


1033-1037: LGTM! Completes the consistency fix.

The change correctly applies the standardized framework conditional for the 1-digit remainder case, completing the alignment across all three parsing scenarios in PlainTextToBinaryNumeric.


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 1, 2025 15:52
{
// Parse the next three characters as a decimal integer.
#if NET5_0_OR_GREATER
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
#if NETCOREAPP || NETSTANDARD2_1

I thinks this could be shortened for better legibility.
Older .NET Core targets than 2.1 aren't present. And .NET (5+) is covered by that compiler constant too.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Well, as written:

  • it matches the rest of the codebase
  • it matches the conditions for which Span is supported

So I'd prefer to leave it as-is here for those reasons. Perhaps it would be better to have a compile time constant defined for span support - similar to SYSTEM_DRAWING we have SPAN - then in the csproj we define it for the applicable target frameworks. Then we change all uses to match.

Copy link
Collaborator

@gfoidl gfoidl left a comment

Choose a reason for hiding this comment

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

Your suggestion with a #define HAS_SPAN (or similar) sound reasonable as follow-up work.

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.

3 participants