From 06a84dcea2bc5b87ad2faf9f9a7cf7a697555918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 2 Feb 2020 09:03:35 +0100 Subject: [PATCH] Code cleanup --- src/map/IMG/huffmanstream.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/map/IMG/huffmanstream.cpp b/src/map/IMG/huffmanstream.cpp index 39c89317..2482664c 100644 --- a/src/map/IMG/huffmanstream.cpp +++ b/src/map/IMG/huffmanstream.cpp @@ -41,21 +41,17 @@ bool HuffmanStream::sign(int &val) bool HuffmanStream::readDelta(int sign, qint32 &symbol) { - uchar size; + quint8 size; + quint32 next; + quint8 nextSize = qMin((quint32)(32 - _symbolDataSize), bitsAvailable()); - if (_symbolDataSize < 32) { - quint32 next; - quint8 nextSize = qMin((quint32)(32 - _symbolDataSize), - bitsAvailable()); + if (!read(nextSize, next)) + return false; - if (!read(nextSize, next)) - return false; + _symbolData = (_symbolData << nextSize) | next; + _symbolDataSize += nextSize; - _symbolData = (_symbolData << nextSize) | next; - _symbolDataSize += nextSize; - } - - symbol = _table.symbol(_symbolData << (32U - _symbolDataSize), size); + symbol = _table.symbol(_symbolData << (32 - _symbolDataSize), size); if (size <= _symbolDataSize) _symbolDataSize -= size;