Deleted unused parameter and simplified code in ReedSolomonGenerator.getRemainder().

pull/134/head
Project Nayuki 6 years ago
parent f8e59274f6
commit 943b8815ee

@ -297,7 +297,7 @@ public final class QrCode {
byte[] ecc = new byte[blockEccLen]; // Temporary storage per iteration byte[] ecc = new byte[blockEccLen]; // Temporary storage per iteration
for (int i = 0, k = 0; i < numBlocks; i++) { for (int i = 0, k = 0; i < numBlocks; i++) {
int datLen = shortBlockDataLen + (i < numShortBlocks ? 0 : 1); int datLen = shortBlockDataLen + (i < numShortBlocks ? 0 : 1);
rs.getRemainder(data, k, datLen, ecc, 0); rs.getRemainder(data, k, datLen, ecc);
for (int j = 0, l = i; j < datLen; j++, k++, l += numBlocks) { // Copy data for (int j = 0, l = i; j < datLen; j++, k++, l += numBlocks) { // Copy data
if (j == shortBlockDataLen) if (j == shortBlockDataLen)
l -= numShortBlocks; l -= numShortBlocks;

@ -122,19 +122,19 @@ final class ReedSolomonGenerator {
} }
public void getRemainder(byte[] data, int dataOff, int dataLen, byte[] result, int resultOff) { public void getRemainder(byte[] data, int dataOff, int dataLen, byte[] result) {
Objects.requireNonNull(data); Objects.requireNonNull(data);
Objects.requireNonNull(result); Objects.requireNonNull(result);
int degree = polynomialMultiply[0].length;
assert result.length == degree;
// Compute the remainder by performing polynomial division // Compute the remainder by performing polynomial division
int degree = polynomialMultiply[0].length; Arrays.fill(result, (byte)0);
int resultEnd = resultOff + degree;
Arrays.fill(result, resultOff, resultEnd, (byte)0);
for (int i = dataOff, dataEnd = dataOff + dataLen; i < dataEnd; i++) { for (int i = dataOff, dataEnd = dataOff + dataLen; i < dataEnd; i++) {
byte[] table = polynomialMultiply[(data[i] ^ result[resultOff]) & 0xFF]; byte[] table = polynomialMultiply[(data[i] ^ result[0]) & 0xFF];
for (int j = 0; j < degree - 1; j++) for (int j = 0; j < degree - 1; j++)
result[resultOff + j] = (byte)(result[resultOff + j + 1] ^ table[j]); result[j] = (byte)(result[j + 1] ^ table[j]);
result[resultOff + degree - 1] = table[degree - 1]; result[degree - 1] = table[degree - 1];
} }
} }

Loading…
Cancel
Save