aboutsummaryrefslogtreecommitdiff
path: root/lib/bunzip.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-01-16 14:25:12 -0500
committerRob Landley <rob@landley.net>2007-01-16 14:25:12 -0500
commitea96222ea514803fa3180de78377e7b00ab8c889 (patch)
tree4cead4801696884d0b34029a5b503acee78c6d26 /lib/bunzip.c
parent636b5cf46650d3aa3bbc9b29feb0e07589085e3f (diff)
downloadtoybox-ea96222ea514803fa3180de78377e7b00ab8c889.tar.gz
Memmove is 11 bytes shorter than the unrolled loop, and Manuel Nova pointed
out how to turn an if/else into a multiply and subtract (saving 2 bytes).
Diffstat (limited to 'lib/bunzip.c')
-rw-r--r--lib/bunzip.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/bunzip.c b/lib/bunzip.c
index fbc6c8e4..5cdc4528 100644
--- a/lib/bunzip.c
+++ b/lib/bunzip.c
@@ -182,7 +182,7 @@ int read_bunzip_data(bunzip_data *bd)
// Decode MTF to get the next selector
uc = mtfSymbol[j];
- for (k=j; k; k--) mtfSymbol[k] = mtfSymbol[k-1];
+ memmove(mtfSymbol+1, mtfSymbol, j);
mtfSymbol[0] = selectors[i] = uc;
}
// Read the huffman coding tables for each group, which code for symTotal
@@ -197,9 +197,8 @@ int read_bunzip_data(bunzip_data *bd)
for (i = 0; i < symCount; i++) {
for(;;) {
if (MAX_HUFCODE_BITS < (unsigned)t-1) return RETVAL_DATA_ERROR;
- if(!get_bits(bd, 1)) break;
- if(!get_bits(bd, 1)) t++;
- else t--;
+ if(!get_bits(bd, 1)) break; // Stop yet?
+ t += (1 - 2*get_bits(bd, 1)); // bit ? t-- : t++
}
length[i] = t;
}