Simplified a small bit of variables and logic of QrCode.getPenaltyScore() in all language versions, but in a subtly different way per language.

This commit is contained in:
Project Nayuki
2017-05-08 07:30:53 +00:00
parent e28c1d718e
commit 0482a1ec5b
5 changed files with 26 additions and 32 deletions
+4 -6
View File
@@ -455,9 +455,8 @@ var qrcodegen = new function() {
// Adjacent modules in row having same color
for (var y = 0; y < size; y++) {
var colorX = modules[y][0];
for (var x = 1, runX = 1; x < size; x++) {
if (modules[y][x] != colorX) {
for (var x = 0, runX, colorX; x < size; x++) {
if (x == 0 || modules[y][x] != colorX) {
colorX = modules[y][x];
runX = 1;
} else {
@@ -471,9 +470,8 @@ var qrcodegen = new function() {
}
// Adjacent modules in column having same color
for (var x = 0; x < size; x++) {
var colorY = modules[0][x];
for (var y = 1, runY = 1; y < size; y++) {
if (modules[y][x] != colorY) {
for (var y = 0, runY, colorY; y < size; y++) {
if (y == 0 || modules[y][x] != colorY) {
colorY = modules[y][x];
runY = 1;
} else {