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

This commit is contained in:
Project Nayuki 2018-11-01 18:00:02 +00:00
parent a24466089b
commit 08886d2a3e
3 changed files with 7 additions and 6 deletions

View File

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

View File

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

View File

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