Skip to content

chore: apply the fixes and cleanup - #514

Open
guitarrapc wants to merge 1 commit into
mainfrom
chore/audit-2026-11-28-cleanup
Open

guitarrapc wants to merge 1 commit into
mainfrom
chore/audit-2026-11-28-cleanup

Conversation

@guitarrapc

Copy link
Copy Markdown
Owner

Summary

Applies the fixes and the cleanup. Most changes remove dead code and redundant work. Three change behavior at edge cases, and test-only switches leave production paths.

Intent

  • Production code should not carry switches that exist only for tests.
  • Every SIMD tier should give the same output for the same input, including input outside the documented range.
  • Code that cannot be reached, and zeroing that the runtime already does, should go.
  • XML docs should describe what the code does.

Before / After

Case Before After
Premultiplied input with a channel above its alpha Results differ between tiers. Some wrap, some saturate Every tier saturates at 255 (white)
Bilinear with huge or infinite coordinates The float-to-int conversion could overflow before the edge clamp Clamped in float, so the edge pixel is read
Synchronous SVG output with an invalid icon or gradient Part of the document could be written before the throw Settings are checked first, so nothing is written
forceScalar in LuminanceConverter / AlignmentPatternFinder A runtime bool on the production path The test entry calls the scalar tier directly. The row scan is a struct type parameter

Benchmarks (in-process, ABBA against main): LuminanceConversion, QRCodeImageDecodeEndToEnd and QRCodeEncodeEndToEnd are within ±10% on Mean and Allocated for all 47 rows. The one row past +10% was a single outlier, and a re-run showed no difference.

Changes

  • Remove the forceScalar parameters. AlignmentPatternFinder selects its row scan through a struct type parameter.
  • Saturate premultiplied luma at 255 on the scalar, AVX2, Vector128 and NEON paths. Document it in the spec and the XML docs.
  • Clamp LuminanceSampler.Bilinear coordinates in float.
  • Validate the icon and gradient before a synchronous SVG render starts writing.
  • Remove unreachable code: the Micro QR format-word search, RowsGeneral and its ARGB parity case, and redundant Math.Min, % 255 and stride > 1 checks.
  • Remove Clear() calls that follow a stackalloc the runtime already zeroed.
  • Drop the alphanumeric rescan in FNC1 reconstruction. Use WriteEci for the FNC1 ECI header (same output).
  • Fix doc mismatches in DecodeStatus, QRCodeDecodeInfo, RmQRSegmentation and the GS1 exceptions.
  • Tests: add cases for premultiplied saturation, extreme Bilinear coordinates and a refused SVG render. Update the parity references to match.

Not verified

The NEON saturating narrow and the portable Vector128 fallback (ARM64 without Dp) have not run on ARM64 hardware.

🤖 Generated with Claude Code

- LuminanceConverter and AlignmentPatternFinder lose the forceScalar switch. The test entry calls validation and the scalar tier directly, and the alignment row scan is a struct type parameter.
- Premultiplied input with a channel above its alpha saturates at 255 on every tier instead of wrapping. The spec and XML docs say so.
- LuminanceSampler.Bilinear clamps in float, so huge or infinite coordinates take the edge pixel.
- Synchronous SVG output checks the icon and gradient before it writes, so a refused render writes nothing.
- Remove unreachable code: the Micro QR format-word search, RowsGeneral and the ARGB parity case, and redundant Min, modulo and stride checks.
- Remove Clear calls that follow a zeroed stackalloc.
- FNC1 reconstruction drops the alphanumeric rescan, and the FNC1 ECI header uses WriteEci.
- Fix doc mismatches in DecodeStatus, QRCodeDecodeInfo, RmQRSegmentation and the GS1 exceptions.
- Add the audit report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant