Skip to content
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

Fix merge mistake in Code128Reader #574

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/oned/Code128Reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default class Code128Reader extends OneDReader {
}
patternStart += counters[0] + counters[1];

counters = counters.slice(2, counters.length - 1);
counters = counters.slice(2, counters.length);
Copy link
Contributor Author

@JanPolasek JanPolasek Sep 14, 2023

Choose a reason for hiding this comment

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

Unfortunately splice() cannot be used here, as that method is only available on normal arrays, but counters is a TypedArray.

The code indeed used to use splice() prior to 0.18.3 when counters was just a regular array, but that has changed a few commits back (and I don't understand the underlying algorithms enough to know whether TypedArrays are really necessary, but they might, considering that the original java ZXing code uses integers there, not floats)

And as to why I chose to go with the longer counters = counters.slice(2, counters.length); - it's because that's what #536 did and I figured I'd just do the same for the sake of consistency, but you are right, the second argument is unnecessary.

Choose a reason for hiding this comment

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

@JanPolasek Good catch!

counters[counterPosition - 1] = 0;
counters[counterPosition] = 0;
counterPosition--;
Expand Down