Skip to content

Commit

Permalink
optimize length decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
zivillian committed Jun 17, 2018
1 parent 1e0b1b9 commit 6a25251
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/LzoStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,10 @@ protected virtual int Decode(byte[] buffer, int offset, int count)
* state = S (copy S literals after this block)
* End of stream is reached if distance == 16384
*/
int length;
var l = Instruction & 0x7;
if (l == 0)
int length = (Instruction & 0x7) + 2;
if (length == 2)
{
length = 2 + 7 + ReadLength();
}
else
{
length = 2 + l;
length += 7 + ReadLength();
}
var s = Source.ReadByte();
var d = Source.ReadByte();
Expand All @@ -225,15 +220,10 @@ protected virtual int Decode(byte[] buffer, int offset, int count)
* distance = D + 1
* state = S (copy S literals after this block)
*/
int length;
var l = Instruction & 0x1f;
if (l == 0)
{
length = 2 + 31 + ReadLength();
}
else
int length = (Instruction & 0x1f) + 2;
if (length == 2)
{
length = 2 + l;
length += 31 + ReadLength();
}
var s = Source.ReadByte();
var d = Source.ReadByte();
Expand Down

0 comments on commit 6a25251

Please sign in to comment.