From 3d0863717a19eab58c7cf21d36cb3f0d8f91115c Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sun, 27 Aug 2017 00:05:52 +0000 Subject: [PATCH] Simplified small bits of Python and JavaScript code, without changing behavior. --- javascript/qrcodegen.js | 3 +-- python/qrcodegen.py | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 836cc1e..8d99604 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -958,8 +958,7 @@ var qrcodegen = new function() { // Compute the remainder by performing polynomial division var result = coefficients.map(function() { return 0; }); data.forEach(function(b) { - var factor = b ^ result[0]; - result.shift(); + var factor = b ^ result.shift(); result.push(0); for (var i = 0; i < result.length; i++) result[i] ^= ReedSolomonGenerator.multiply(coefficients[i], factor); diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 69677f3..b150273 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -331,10 +331,10 @@ class QrCode(object): """Draws a 9*9 finder pattern including the border separator, with the center module at (x, y).""" for i in range(-4, 5): for j in range(-4, 5): - dist = max(abs(i), abs(j)) # Chebyshev/infinity norm xx, yy = x + j, y + i if (0 <= xx < self._size) and (0 <= yy < self._size): - self._set_function_module(xx, yy, dist not in (2, 4)) + # Chebyshev/infinity norm + self._set_function_module(xx, yy, max(abs(i), abs(j)) not in (2, 4)) def _draw_alignment_pattern(self, x, y): @@ -805,8 +805,7 @@ class _ReedSolomonGenerator(object): # Compute the remainder by performing polynomial division result = [0] * len(self.coefficients) for b in data: - factor = (b ^ result[0]) - del result[0] + factor = b ^ result.pop(0) result.append(0) for i in range(len(result)): result[i] ^= _ReedSolomonGenerator._multiply(self.coefficients[i], factor)