Synchronized some code with the parent project, without changing behavior.

pull/134/head
Project Nayuki 5 years ago
parent 6d6e0f3fde
commit afc12dc9d2

@ -458,8 +458,8 @@ public final class QrCode {
if (mask == -1) { // Automatically choose best mask if (mask == -1) { // Automatically choose best mask
int minPenalty = Integer.MAX_VALUE; int minPenalty = Integer.MAX_VALUE;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
drawFormatBits(i);
applyMask(masks[i]); applyMask(masks[i]);
drawFormatBits(i);
int penalty = getPenaltyScore(); int penalty = getPenaltyScore();
if (penalty < minPenalty) { if (penalty < minPenalty) {
mask = i; mask = i;
@ -469,8 +469,8 @@ public final class QrCode {
} }
} }
assert 0 <= mask && mask <= 7; assert 0 <= mask && mask <= 7;
drawFormatBits(mask); // Overwrite old format bits
applyMask(masks[mask]); // Apply the final choice of mask applyMask(masks[mask]); // Apply the final choice of mask
drawFormatBits(mask); // Overwrite old format bits
return mask; // The caller shall assign this value to the final-declared field return mask; // The caller shall assign this value to the final-declared field
} }

@ -81,7 +81,6 @@ public final class QrCodeGeneratorWorker {
else else
segs = Arrays.asList(QrSegment.makeBytes(data)); segs = Arrays.asList(QrSegment.makeBytes(data));
try { // Try to make QR Code symbol try { // Try to make QR Code symbol
QrCode qr = QrCode.encodeSegments(segs, QrCode.Ecc.values()[errCorLvl], minVersion, maxVersion, mask, boostEcl != 0); QrCode qr = QrCode.encodeSegments(segs, QrCode.Ecc.values()[errCorLvl], minVersion, maxVersion, mask, boostEcl != 0);
// Print grid of modules // Print grid of modules

@ -92,7 +92,7 @@ final class ReedSolomonGenerator {
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8. // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
private static int multiply(int x, int y) { private static int multiply(int x, int y) {
assert x >>> 8 == 0 && y >>> 8 == 0; assert x >> 8 == 0 && y >> 8 == 0;
// Russian peasant multiplication // Russian peasant multiplication
int z = 0; int z = 0;
for (int i = 7; i >= 0; i--) { for (int i = 7; i >= 0; i--) {

Loading…
Cancel
Save