Simplified some code, without changing behavior.

pull/134/head
Project Nayuki 6 years ago
parent 7fa8becaf7
commit cdb9172032

@ -129,7 +129,7 @@ public final class QrCode {
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) {
// Check arguments
Objects.requireNonNull(ecl);
errorCorrectionLevel = Objects.requireNonNull(ecl);
if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7)
throw new IllegalArgumentException("Value out of range");
Objects.requireNonNull(dataCodewords);
@ -137,7 +137,6 @@ public final class QrCode {
// Initialize fields
version = ver;
size = ver * 4 + 17;
errorCorrectionLevel = ecl;
QrTemplate tpl = QrTemplate.getInstance(ver);
modules = tpl.template.clone();

@ -156,13 +156,11 @@ public final class QrSegment {
/*---- Constructor ----*/
public QrSegment(Mode md, int numCh, int[] data, int bitLen) {
Objects.requireNonNull(md);
Objects.requireNonNull(data);
mode = Objects.requireNonNull(md);
this.data = Objects.requireNonNull(data);
if (numCh < 0 || bitLen < 0 || bitLen > data.length * 32)
throw new IllegalArgumentException("Invalid value");
mode = md;
numChars = numCh;
this.data = data;
bitLength = bitLen;
}

@ -285,13 +285,8 @@ final class QrTemplate {
return new int[]{};
else {
int numAlign = ver / 7 + 2;
int step;
if (ver != 32) {
// ceil((size - 13) / (2*numAlign - 2)) * 2
step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2;
} else // C-C-C-Combo breaker!
step = 26;
int step = (ver == 32) ? 26 :
(ver*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
int[] result = new int[numAlign];
result[0] = 6;
for (int i = result.length - 1, pos = ver * 4 + 10; i >= 1; i--, pos -= step)

Loading…
Cancel
Save