aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-01-19 16:31:11 -0500
committerRob Landley <rob@landley.net>2007-01-19 16:31:11 -0500
commit94515a2803d8db4b5a0c1cc51554f79a98803891 (patch)
tree810d780e2c79d27993b5e6d136b7045cec3a8136
parent59b301786890b909d64ddc61e279394184fd57d7 (diff)
downloadtoybox-94515a2803d8db4b5a0c1cc51554f79a98803891.tar.gz
Merge two similar loops and expand a comment.
-rw-r--r--lib/bunzip.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/bunzip.c b/lib/bunzip.c
index 7804b7fa..139848e7 100644
--- a/lib/bunzip.c
+++ b/lib/bunzip.c
@@ -211,8 +211,10 @@ int read_bunzip_data(bunzip_data *bd)
/* Calculate permute[], base[], and limit[] tables from length[].
*
* permute[] is the lookup table for converting huffman coded symbols
- * into decoded symbols. base[] is the amount to subtract from the
- * value of a huffman symbol of a given length when using permute[].
+ * into decoded symbols. It contains symbol values sorted by length.
+ *
+ * base[] is the amount to subtract from the value of a huffman symbol
+ * of a given length when using permute[].
*
* limit[] indicates the largest numerical value a symbol with a given
* number of bits can have. It lets us know when to stop reading.
@@ -231,20 +233,20 @@ int read_bunzip_data(bunzip_data *bd)
base = hufGroup->base-1;
limit = hufGroup->limit-1;
- // Calculate permute[]
+ // Calculate permute[], and zero temp[] and limit[].
pp = 0;
for (i = minLen; i <= maxLen; i++)
+ temp[i] = limit[i] = 0;
for (t = 0; t < symCount; t++)
if (length[t] == i) hufGroup->permute[pp++] = t;
- // Count cumulative symbols coded for at each bit length
- for (i = minLen; i <= maxLen; i++) temp[i] = limit[i] = 0;
+ // Count symbols coded for at each bit length
for (i = 0; i < symCount; i++) temp[length[i]]++;
/* Calculate limit[] (the largest symbol-coding value at each bit
* length, which is (previous limit<<1)+symbols at this level), and
* base[] (number of symbols to ignore at each bit length, which is
- * limit-cumulative count of symbols coded for already). */
+ * limit minus the cumulative count of symbols coded for already). */
pp = t = 0;
for (i = minLen; i < maxLen; i++) {
pp += temp[i];