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

Simplified some code #596

Merged
merged 9 commits into from May 12, 2016
Merged

Simplified some code #596

merged 9 commits into from May 12, 2016

Conversation

tanelihuuskonen
Copy link
Contributor

Simplified a few bits of code in BitArray and RGBLuminanceSource, improving performance at least marginally.

Bug #593 was misleadingly reported as pertaining to another project, but
testing revealed it affected this project as well.  The Code128 encoding
algorithm failed when an odd number of digits were followed by FNC1 and
other digits.  The code selection algorithm was rewritten.  A test case
showing the bug was added, and an old test case was updated to expect
the result of the new algorithm  -  another valid encoding of the same
length as the old one.
Bug #593 was misleadingly reported as pertaining to another project, but
testing revealed it affected this project as well.  The Code128 encoding
algorithm failed when an odd number of digits were followed by FNC1 and
other digits.  The code selection algorithm was rewritten.  A test case
showing the bug was added, and an old test case was updated to expect
the result of the new algorithm  -  another valid encoding of the same
length as the old one.
Removed imports I didn't use after all.
Added a private enum and changed some names to improve readability.
Also some trivial cosmetic changes.
Removed a private one-liner method used exactly once, alphabetized
imports.
Removed testing every pixel for greyness in RGBLuminanceSource, as it
did not appreciably change the speed of converting a greyscale image and
slowed down the conversion of a colour image by a few percent.  Besides,
there was no need to treat every row separately; the total number of
pixels was enough.
Simplified some code, added more accurate error checking, and corrected
small inaccuracies in comments.
}
}
// Ones from firstBit to lastBit, inclusive
int mask = (2 << lastBit) - (1 << firstBit);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's pretty cool, never though of writing it this way. Seems to work. You can inline this in the line below if you like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that makes sense. Done.

@srowen
Copy link
Contributor

srowen commented May 12, 2016

Yeah looks like nice optimizations, well done. I'll merge it when I get back.

@srowen srowen merged commit cc16a72 into zxing:master May 12, 2016
@tanelihuuskonen
Copy link
Contributor Author

Thanks. I like that kind of stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants