Skip to content
Permalink
Browse files

ZVISION: Move early break out above the for loop. LzssReadStream::dec…

…ompressBytes()

The other code would go through each of the for loops and do nothing due to EOS.
  • Loading branch information...
RichieSams committed Jul 7, 2013
1 parent 399e512 commit ca89f7679881aeb2ce056592f5d38531db2465fd
Showing with 37 additions and 37 deletions.
  1. +37 −37 engines/zvision/lzss_read_stream.cpp
@@ -52,49 +52,49 @@ void LzssReadStream::decompressBytes(uint32 numberOfBytes) {

while (!_source->eos() && bytesRead <= numberOfBytes) {
byte flagbyte = _source->readByte();
if (_source->eos())
break;
byte mask = 1;

for (uint32 i = 0; i < 8; i++) {
if (!_source->eos()) {
if ((flagbyte & mask) == mask)
if ((flagbyte & mask) == mask)
{
byte data = _source->readByte();
bytesRead++;
if (_source->eos())
break;

_window[_windowCursor] = data;
_destination.push_back(data);

// Increment and wrap the window cursor
_windowCursor = (_windowCursor + 1) & 0xFFF;
}
else
{
byte low = _source->readByte();
bytesRead++;
if (_source->eos())
break;

byte high = _source->readByte();
bytesRead++;
if (_source->eos())
break;

uint16 length = (high & 0xF) + 2;
uint16 offset = low | ((high & 0xF0)<<4);

for(byte j = 0; j <= length; j++)
{
byte data = _source->readByte();
bytesRead++;
if (_source->eos())
break;

_window[_windowCursor] = data;
_destination.push_back(data);

// Increment and wrap the window cursor
byte temp = _window[(offset + j) & 0xFFF];
_window[_windowCursor] = temp;
_destination.push_back(temp);
_windowCursor = (_windowCursor + 1) & 0xFFF;
}
else
{
byte low = _source->readByte();
bytesRead++;
if (_source->eos())
break;

byte high = _source->readByte();
bytesRead++;
if (_source->eos())
break;

uint16 length = (high & 0xF) + 2;
uint16 offset = low | ((high & 0xF0)<<4);

for(byte j = 0; j <= length; j++)
{
byte temp = _window[(offset + j) & 0xFFF];
_window[_windowCursor] = temp;
_destination.push_back(temp);
_windowCursor = (_windowCursor + 1) & 0xFFF;
}
};

mask = mask << 1;
}
};

mask = mask << 1;
}
}
}

0 comments on commit ca89f76

Please sign in to comment.
You can’t perform that action at this time.