From f4f971f3847c6f9b9d498cd22e66ebbe850078d6 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Mon, 5 Nov 2018 05:10:33 +0000 Subject: [PATCH] Inverted some if-else statements in getPenaltyScore(). --- src/io/nayuki/fastqrcodegen/QrCode.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/io/nayuki/fastqrcodegen/QrCode.java b/src/io/nayuki/fastqrcodegen/QrCode.java index b3bac2a..ccf474d 100644 --- a/src/io/nayuki/fastqrcodegen/QrCode.java +++ b/src/io/nayuki/fastqrcodegen/QrCode.java @@ -492,15 +492,15 @@ public final class QrCode { // Adjacent modules having same color int c = getBit(modules[index >>> 5], index); - if (c != color) { - color = c; - runX = 1; - } else { + if (c == color) { runX++; if (runX == 5) result += PENALTY_N1; else if (runX > 5) result++; + } else { + color = c; + runX = 1; } black += c; @@ -527,15 +527,15 @@ public final class QrCode { // Adjacent modules having same color int c = getBit(modules[index >>> 5], index); - if (c != color) { - color = c; - runY = 1; - } else { + if (c == color) { runY++; if (runY == 5) result += PENALTY_N1; else if (runY > 5) result++; + } else { + color = c; + runY = 1; } // Finder-like pattern