diff --git a/src/io/nayuki/fastqrcodegen/QrCode.java b/src/io/nayuki/fastqrcodegen/QrCode.java index dfe4448..95242d5 100644 --- a/src/io/nayuki/fastqrcodegen/QrCode.java +++ b/src/io/nayuki/fastqrcodegen/QrCode.java @@ -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(); diff --git a/src/io/nayuki/fastqrcodegen/QrSegment.java b/src/io/nayuki/fastqrcodegen/QrSegment.java index c0cc5b3..ea48ce1 100644 --- a/src/io/nayuki/fastqrcodegen/QrSegment.java +++ b/src/io/nayuki/fastqrcodegen/QrSegment.java @@ -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; } diff --git a/src/io/nayuki/fastqrcodegen/QrTemplate.java b/src/io/nayuki/fastqrcodegen/QrTemplate.java index 37d292b..61acfa6 100644 --- a/src/io/nayuki/fastqrcodegen/QrTemplate.java +++ b/src/io/nayuki/fastqrcodegen/QrTemplate.java @@ -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)