From 47541e1b29df1aad8010d81af144fc1bc44fae72 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Mon, 5 Nov 2018 05:17:45 +0000 Subject: [PATCH] Simplified some code in getPenaltyScore(). --- src/io/nayuki/fastqrcodegen/QrCode.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/io/nayuki/fastqrcodegen/QrCode.java b/src/io/nayuki/fastqrcodegen/QrCode.java index fe337ad..2fd362d 100644 --- a/src/io/nayuki/fastqrcodegen/QrCode.java +++ b/src/io/nayuki/fastqrcodegen/QrCode.java @@ -506,11 +506,11 @@ public final class QrCode { runX = 1; } black += c; - curRow = ((curRow & 0b1111111111) << 1) | c; if (downIndex < end) { - nextRow = ((nextRow & 1) << 1) | getBit(modules[downIndex >>> 5], downIndex); + curRow = ((curRow << 1) | c) & 3; + nextRow = ((nextRow << 1) | getBit(modules[downIndex >>> 5], downIndex)) & 3; // 2*2 blocks of modules having same color - if (x >= 1 && (nextRow == 0 || nextRow == 3) && nextRow == (curRow & 3)) + if (x >= 1 && (curRow == 0 || curRow == 3) && curRow == nextRow) result += PENALTY_N2; } }