Simplified the argument check in BitBuffer.appendBits() by tightening the input range, also removed some parentheses.

This commit is contained in:
Project Nayuki
2017-08-18 03:33:03 +00:00
parent 7e512971df
commit 97e0388cb7
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ std::vector<std::uint8_t> BitBuffer::getBytes() const {
void BitBuffer::appendBits(std::uint32_t val, int len) {
if (len < 0 || len > 32 || (len < 32 && (val >> len) != 0))
if (len < 0 || len > 31 || val >> len != 0)
throw "Value out of range";
for (int i = len - 1; i >= 0; i--) // Append bit by bit
this->push_back(((val >> i) & 1) != 0);