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 -8
View File
@@ -436,10 +436,8 @@ class QrCode(object):
# Adjacent modules in row having same color
for y in range(size):
colorx = modules[y][0]
runx = 1
for x in range(1, size):
if modules[y][x] != colorx:
for x in range(size):
if x == 0 or modules[y][x] != colorx:
colorx = modules[y][x]
runx = 1
else:
@@ -450,10 +448,8 @@ class QrCode(object):
result += 1
# Adjacent modules in column having same color
for x in range(size):
colory = modules[0][x]
runy = 1
for y in range(1, size):
if modules[y][x] != colory:
for y in range(size):
if y == 0 or modules[y][x] != colory:
colory = modules[y][x]
runy = 1
else: