Simplified a bit of code in JavaScript, TypeScript, Python.

pull/51/head
Project Nayuki 6 years ago
parent a24466089b
commit 08886d2a3e

@ -997,8 +997,9 @@ var qrcodegen = new function() {
data.forEach(function(b) { data.forEach(function(b) {
var factor = b ^ result.shift(); var factor = b ^ result.shift();
result.push(0); result.push(0);
for (var i = 0; i < result.length; i++) coefficients.forEach(function(coef, i) {
result[i] ^= ReedSolomonGenerator.multiply(coefficients[i], factor); result[i] ^= ReedSolomonGenerator.multiply(coef, factor);
});
}); });
return result; return result;
}; };

@ -870,8 +870,8 @@ class _ReedSolomonGenerator(object):
for b in data: for b in data:
factor = b ^ result.pop(0) factor = b ^ result.pop(0)
result.append(0) result.append(0)
for i in range(len(result)): for (i, coef) in enumerate(self.coefficients):
result[i] ^= _ReedSolomonGenerator._multiply(self.coefficients[i], factor) result[i] ^= _ReedSolomonGenerator._multiply(coef, factor)
return result return result

@ -925,8 +925,8 @@ namespace qrcodegen {
for (const b of data) { for (const b of data) {
const factor: byte = b ^ (result.shift() as int); const factor: byte = b ^ (result.shift() as int);
result.push(0); result.push(0);
for (let i = 0; i < result.length; i++) this.coefficients.forEach((coef, i) =>
result[i] ^= ReedSolomonGenerator.multiply(this.coefficients[i], factor); result[i] ^= ReedSolomonGenerator.multiply(coef, factor));
} }
return result; return result;
} }

Loading…
Cancel
Save