return *const_cast<BlockInfo*>(BI);
// Otherwise, add a new record.
- BlockInfoRecords.push_back(BlockInfo());
+ BlockInfoRecords.emplace_back();
BlockInfoRecords.back().BlockID = BlockID;
return BlockInfoRecords.back();
}
public:
+ static const size_t MaxChunkSize = sizeof(word_t) * 8;
+
BitstreamCursor() { init(nullptr); }
explicit BitstreamCursor(BitstreamReader &R) { init(&R); }
// If we run out of data, stop at the end of the stream.
if (BytesRead == 0) {
+ CurWord = 0;
+ BitsInCurWord = 0;
Size = NextChar;
return;
}
}
word_t Read(unsigned NumBits) {
- static const unsigned BitsInWord = sizeof(word_t) * 8;
+ static const unsigned BitsInWord = MaxChunkSize;
assert(NumBits && NumBits <= BitsInWord &&
"Cannot return zero or more than BitsInWord bits!");
// Read a VBR that may have a value up to 64-bits in size. The chunk size of
// the VBR must still be <= 32 bits though.
uint64_t ReadVBR64(unsigned NumBits) {
- assert(NumBits <= 64 && "VBR can only be up to 64 bits in size.");
uint32_t Piece = Read(NumBits);
if ((Piece & (1U << (NumBits-1))) == 0)
return uint64_t(Piece);