Skip to content

barcodes: final review pass - #321

Merged
shreeve merged 2 commits into
mainfrom
barcodes-final-pass
Sep 16, 2026
Merged

shreeve merged 2 commits into
mainfrom
barcodes-final-pass

Conversation

@shreeve

@shreeve shreeve commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

One last pass over every file in packages/barcodes: four read-only reviews (qr.rip; pdf417.rip; code128/image/gif/eci/barcodes/package.json; README/dom/test), acting only on errors.

  • QR: the global-projection fallback after the tile pass now rebuilds the finder map and its fine-plane form; the tiles built their homographies in the same matrices, so the fallback ran on the last tile's map and failed on every fine-plane path. Two pieces of dead code removed; two comments now say what the code checks.
  • Code 128: a mirrored symbol flush against the image's left edge did not read, because a reversed line that opened dark ends in an empty run that the stop's quiet-zone test rejected. Fixed and tested for both flush cases.
  • PDF417: two functions made void so a trailing loop no longer collects an array per codeword; corners across the symbol come from the tracked tail edge; the header describes the two-edge reader; three comment corrections and one unreachable guard removed.
  • ECI 12 (ISO-8859-10) added to the table.
  • README: removed the false advice to upscale 1-pixel QR rasters (they decode), replaced the python-qrcode claim with the reference implementation the vectors prove, rewrapped two paragraphs.

Verification

  • Package suite 42 tests; bun run test:all 26 lanes, 9,904 tests green.
  • QR parity against paulmillr/qr unchanged: encoder 1,452 checks, decoder 192 checks, 0 mismatches.
  • ZXing PDF417 blackbox sets 1-3: 58/58 at 0, 90, 180 and 270 degrees.
  • Benchmarks (Bun 1.4.0, M5) match or beat the README on every row: QR encode 2.5/14.6/45.9 µs, decode 28.4 µs / 577 µs / 1.32 ms, miss 5.92 ms; Code 128 720p read 5.2 µs; PDF417 1080p decode 344 µs, noise 299 µs.

Four read-only reviews of every file, acting only on errors.

QR: the global-projection fallback after the tile pass rebuilds the
finder map and its fine-plane form, since the tiles built their
homographies in the same matrices; as written it ran on the last tile's
map and failed on every fine-plane path. The unreachable hasError flag
in correctBlock and the unused test parameter of drawSymbol are gone.
The timing and scan comments say what the code checks. Encoder parity
1452/0 and decoder parity 192/0 against the reference are unchanged.

Code 128: a reversed line that opened dark ends in an empty run, which
the stop's quiet-zone test rejected, so a mirrored symbol flush against
the image's left edge did not read; the test covers both flush cases.
The checksum leaves _tests, which the suite never used.

PDF417: put and Stream.decimal are void, since a trailing loop collects
an array per codeword otherwise; the corners across the symbol come from
the tracked tail edge plus its pattern width when that edge was tracked;
the header describes the two-edge reader; the readFrom and row-fit
comments name what first and the indicator are; a guard edgeRuns could
never take is gone; tryDecode's summary sits above tryDecode. ZXing sets
1-3 stay 58/58 at four rotations.

ECI 12 (ISO-8859-10) joins the table.

README: a clean QR raster decodes at one pixel per module, as the suite
and a direct check show, so the advice to upscale is gone; the encoder
matches the reference implementation, which the vectors prove, not
python-qrcode; two paragraphs rewrapped. A test comment names the
symbol's true shape, nine rows of two columns.

Benchmarks (Bun 1.4.0, M5) match or beat the README on every row: QR
encode 2.5/14.6/45.9 µs, decode 28.4 µs/577 µs/1.32 ms, miss 5.92 ms;
Code 128 720p read 5.2 µs; PDF417 1080p decode 344 µs, noise 299 µs.
@shreeve
shreeve merged commit 2ca8d99 into main Sep 16, 2026
2 checks passed
@shreeve
shreeve deleted the barcodes-final-pass branch September 16, 2026 22:57
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