1. Move method

2. addTerminator in QrCode
3. Feature envy. It calls only BitBuffer methods.
pull/90/head
gerzees 5 years ago
parent 889fc7d9d5
commit 62ad71d6d7

@ -141,5 +141,13 @@ public final class BitBuffer implements Cloneable {
dataCodewords[i >>> 3] |= getBit(i) << (7 - (i & 7));
return dataCodewords;
}
// Add terminator and pad up to a byte if applicable
public void addTerminator(int dataCapacityBits) {
appendBits(0, Math.min(4, dataCapacityBits - bitLength()));
appendBits(0, (8 - bitLength() % 8) % 8);
assert bitLength() % 8 == 0;
}
}

@ -169,7 +169,7 @@ public final class QrCode {
int dataCapacityBits = getNumDataCodewords(version, errorCorrectionLevel) * 8;
assert bitBuffer.bitLength() <= dataCapacityBits;
addTerminator(bitBuffer, dataCapacityBits);
bitBuffer.addTerminator(dataCapacityBits);
bitBuffer.addPad(dataCapacityBits);
@ -184,12 +184,6 @@ public final class QrCode {
/*---- Private helper methods for encodeSegments ----*/
// Add terminator and pad up to a byte if applicable
private static void addTerminator(BitBuffer bitBuffer, int dataCapacityBits) {
bitBuffer.appendBits(0, Math.min(4, dataCapacityBits - bitBuffer.bitLength()));
bitBuffer.appendBits(0, (8 - bitBuffer.bitLength() % 8) % 8);
assert bitBuffer.bitLength() % 8 == 0;
}
// Concatenate all segments to create the data bit string
private static BitBuffer segmentsToBitBuffer(List<QrSegment> segments, int version) {

Loading…
Cancel
Save