aboutsummaryrefslogtreecommitdiff
path: root/lib/bunzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bunzip.c')
-rw-r--r--lib/bunzip.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/bunzip.c b/lib/bunzip.c
index 96f7a871..7804b7fa 100644
--- a/lib/bunzip.c
+++ b/lib/bunzip.c
@@ -188,8 +188,15 @@ int read_bunzip_data(bunzip_data *bd)
// !t || t > MAX_HUFCODE_BITS in one test.
if (MAX_HUFCODE_BITS-1 < (unsigned)t-1)
return RETVAL_DATA_ERROR;
- if(!get_bits(bd, 1)) break; // Stop yet?
- t += (1 - 2*get_bits(bd, 1)); // bit ? t-- : t++
+ // Grab 2 bits instead of 1 (slightly smaller/faster). Stop if
+ // first bit is 0, otherwise second bit says whether to
+ // increment or decrement.
+ k = get_bits(bd, 2);
+ if (k & 2) t += 1 - ((k&1)<<1);
+ else {
+ bd->inbufBitCount++;
+ break;
+ }
}
length[i] = t;
}