mirror of
https://github.com/openharmony/third_party_qrcodegen.git
synced 2026-07-20 23:56:51 -04:00
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:
@@ -31,14 +31,6 @@ BitBuffer::BitBuffer()
|
||||
: std::vector<bool>() {}
|
||||
|
||||
|
||||
std::vector<std::uint8_t> BitBuffer::getBytes() const {
|
||||
std::vector<std::uint8_t> result(size() / 8 + (size() % 8 == 0 ? 0 : 1));
|
||||
for (std::size_t i = 0; i < size(); i++)
|
||||
result[i >> 3] |= (*this)[i] ? 1 << (7 - (i & 7)) : 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void BitBuffer::appendBits(std::uint32_t val, int len) {
|
||||
if (len < 0 || len > 31 || val >> len != 0)
|
||||
throw std::domain_error("Value out of range");
|
||||
|
||||
Reference in New Issue
Block a user