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
Simplified some code #596
Conversation
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); |
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.
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.
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.
Right, that makes sense. Done.
Yeah looks like nice optimizations, well done. I'll merge it when I get back. |
Thanks. I like that kind of stuff. |
Simplified a few bits of code in BitArray and RGBLuminanceSource, improving performance at least marginally.