Inlined BitBuffer.getBytes() into its single usage (with simplification because the bit length is a multiple of 8) in most language versions, synchronized comment and variable name in Rust version.

This commit is contained in:
Project Nayuki
2018-10-06 04:44:03 +00:00
parent 8c262c00dd
commit c7bc281e18
9 changed files with 40 additions and 69 deletions
+6 -1
View File
@@ -109,8 +109,13 @@ QrCode QrCode::encodeSegments(const vector<QrSegment> &segs, Ecc ecl,
for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
bb.appendBits(padByte, 8);
// Pack bits into bytes in big endian
vector<uint8_t> dataCodewords(bb.size() / 8);
for (size_t i = 0; i < bb.size(); i++)
dataCodewords[i >> 3] |= (bb.at(i) ? 1 : 0) << (7 - (i & 7));
// Create the QR Code object
return QrCode(version, ecl, bb.getBytes(), mask);
return QrCode(version, ecl, dataCodewords, mask);
}