1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:08:12 +00:00

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
parent febc8a5ac7
commit e77031ce67
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];