From 0bf2d3306bbb0a72776c53b1d3219920e01cfc1d Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Tue, 28 Aug 2018 07:18:56 +0000 Subject: [PATCH] Simplified some code. --- c/qrcodegen.c | 12 +++++------- java/io/nayuki/qrcodegen/QrCode.java | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 16bb0ff..2c5389a 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -202,7 +202,7 @@ testable void addEccAndInterleave(uint8_t data[], int version, enum qrcodegen_Ec int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version]; int blockEccLen = ECC_CODEWORDS_PER_BLOCK[(int)ecl][version]; int rawCodewords = getNumRawDataModules(version) / 8; - int dataLen = rawCodewords - blockEccLen * numBlocks; + int dataLen = getNumDataCodewords(version, ecl); int numShortBlocks = numBlocks - rawCodewords % numBlocks; int shortBlockDataLen = rawCodewords / numBlocks - blockEccLen; @@ -384,12 +384,10 @@ static void drawWhiteFunctionModules(uint8_t qrcode[], int version) { for (int i = 0; i < numAlign; i++) { for (int j = 0; j < numAlign; j++) { if ((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0)) - continue; // Skip the three finder corners - else { - for (int k = -1; k <= 1; k++) { - for (int l = -1; l <= 1; l++) - setModule(qrcode, alignPatPos[i] + l, alignPatPos[j] + k, k == 0 && l == 0); - } + continue; // Don't draw on the three finder corners + for (int k = -1; k <= 1; k++) { + for (int l = -1; l <= 1; l++) + setModule(qrcode, alignPatPos[i] + l, alignPatPos[j] + k, k == 0 && l == 0); } } } diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index 6da7a16..4890fed 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -688,7 +688,7 @@ public final class QrCode { result -= (numAlign - 2) * 2 * 20; // Subtract alignment patterns that overlap with timing patterns // The two lines above are equivalent to: result -= (25 * numAlign - 10) * numAlign - 55; if (ver >= 7) - result -= 18 * 2; // Subtract version information + result -= 6 * 3 * 2; // Subtract version information } return result; }