mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 12:28:13 -04:00
feat(ricepp): another 15% decode speedup
This commit is contained in:
parent
107a89425e
commit
4811199406
@ -65,6 +65,10 @@ class bitstream_reader final {
|
||||
size_t find_first_set() {
|
||||
size_t zeros = 0;
|
||||
if (bit_pos_ != 0) [[likely]] {
|
||||
if (peek_bit()) [[likely]] {
|
||||
skip_bits(1);
|
||||
return zeros;
|
||||
}
|
||||
size_t const remaining_bits = kBitsTypeBits - bit_pos_;
|
||||
bits_type const bits = peek_bits(remaining_bits);
|
||||
size_t const ffs = std::countr_zero(bits);
|
||||
@ -107,6 +111,11 @@ class bitstream_reader final {
|
||||
}
|
||||
}
|
||||
|
||||
bool peek_bit() {
|
||||
assert(bit_pos_ > 0 && bit_pos_ < kBitsTypeBits);
|
||||
return (data_ & (static_cast<bits_type>(1) << bit_pos_)) != 0;
|
||||
}
|
||||
|
||||
bits_type peek_bits(size_t num_bits) {
|
||||
assert(bit_pos_ + num_bits <= kBitsTypeBits);
|
||||
if (bit_pos_ == 0) [[unlikely]] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user