-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add postscript renderer optimizations #651
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
Conversation
📝 WalkthroughWalkthroughRefactors PostScript generation in QRCoder/PostscriptQRCode.cs to build output with a pre-sized StringBuilder and updates CleanSvgVal to format doubles with "G7" using invariant culture. Approved PostScript test baselines were updated to match the new textual output formatting and newline placement. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
QRCoder/PostscriptQRCode.cs(3 hunks)QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_colors.approved.txt(1 hunks)QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_eps.approved.txt(1 hunks)QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_simple.approved.txt(1 hunks)QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_size.approved.txt(1 hunks)QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_size_no_quiet_zones.approved.txt(1 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). (6)
- GitHub Check: Test .NET 6.0 Windows
- GitHub Check: Test .NET Core 2.1
- GitHub Check: Test .NET Framework 4.6.2
- GitHub Check: Test .NET Core 3.1
- GitHub Check: Test .NET 5.0 Windows
- GitHub Check: additional-tests
🔇 Additional comments (7)
QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_eps.approved.txt (1)
53-85: LGTM! Baseline correctly reflects StringBuilder formatting changes.The updated PostScript drawing commands now append "nl" inline at the end of each row (except the last), matching the StringBuilder-based assembly logic introduced in the production code. The rendering output remains functionally identical.
QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_simple.approved.txt (1)
53-85: LGTM! Baseline correctly reflects StringBuilder formatting changes.The drawing command sequence has been reformatted with inline "nl" tokens, consistent with the StringBuilder-based assembly in the production code. No functional changes to the rendered output.
QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_size.approved.txt (1)
53-85: LGTM! Baseline correctly reflects StringBuilder formatting changes.The reformatted PostScript body aligns with the StringBuilder-based output from the production code, with "nl" tokens appended inline. Rendering semantics are preserved.
QRCoder/PostscriptQRCode.cs (2)
113-134: LGTM! StringBuilder optimization is well-implemented.The transition from string concatenation to StringBuilder with precomputed capacity improves performance and reduces allocations. The loop logic correctly appends "nl\n" at the beginning of each iteration (except the first), effectively placing "nl" at the end of each row except the last, matching the updated test baselines.
141-142: LGTM! Number formatting improved.The "G7" format specifier limits output to 7 significant digits while preserving precision, and using InvariantCulture ensures consistent formatting across locales.
QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_size_no_quiet_zones.approved.txt (1)
53-77: LGTM! Baseline correctly reflects StringBuilder formatting changes.The PostScript body has been reformatted with inline "nl" tokens, consistent with the StringBuilder-based assembly. The reduced row count reflects the
drawQuietZones=falsesetting, with rendering output functionally unchanged.QRCoderTests/PostscriptQRCodeRendererTests.can_render_postscript_qrcode_colors.approved.txt (1)
53-85: LGTM! Baseline correctly reflects StringBuilder formatting changes.The drawing commands have been reformatted with inline "nl" tokens while preserving the custom color definitions (red foreground, blue background). Rendering output remains functionally identical.
gfoidl
left a comment
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.
Really lovely your clean and concise PRs.
Summary by CodeRabbit