AK: Deal with unsigned integers in binary search.

This commit is contained in:
asynts 2021-01-01 21:32:59 +01:00 committed by Andreas Kling
commit e77031ce67
Notes: sideshowbarker 2024-07-19 00:15:40 +09:00
3 changed files with 32 additions and 6 deletions

View file

@ -109,8 +109,10 @@ u32 CanonicalCode::read_symbol(InputBitStream& stream) const
for (;;) {
code_bits = code_bits << 1 | stream.read_bits(1);
ASSERT(code_bits < (1 << 16));
// FIXME: This seems really inefficient, this could be an index into an array instead.
// FIXME: This is very inefficent and could greatly be improved by implementing this
// algorithm: https://www.hanshq.net/zip.html#huffdec
size_t index;
if (AK::binary_search(m_symbol_codes.span(), code_bits, &index))
return m_symbol_values[index];