decompress_uncompress: move 'code' variable into loop - sole user
Apparently, gcc does this optimization itself, since generated code is the same.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/archival/libarchive/decompress_uncompress.c b/archival/libarchive/decompress_uncompress.c
index e9bbfb9..4ccc8a6 100644
--- a/archival/libarchive/decompress_uncompress.c
+++ b/archival/libarchive/decompress_uncompress.c
@@ -78,7 +78,6 @@
IF_DESKTOP(long long total_written = 0;)
IF_DESKTOP(long long) int retval = -1;
unsigned char *stackp;
- long code;
int finchar;
long oldcode;
long incode;
@@ -143,8 +142,10 @@
/* As above, initialize the first 256 entries in the table. */
/*clear_tab_prefixof(); - done by xzalloc */
- for (code = 255; code >= 0; --code) {
- tab_suffixof(code) = (unsigned char) code;
+ {
+ int i;
+ for (i = 255; i >= 0; --i)
+ tab_suffixof(i) = (unsigned char) i;
}
do {
@@ -175,6 +176,8 @@
(insize << 3) - (n_bits - 1));
while (inbits > posbits) {
+ long code;
+
if (free_ent > maxcode) {
posbits =
((posbits - 1) +
@@ -191,13 +194,12 @@
}
{
unsigned char *p = &inbuf[posbits >> 3];
-
- code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
- ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
+ code = ((p[0]
+ | ((long) (p[1]) << 8)
+ | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
}
posbits += n_bits;
-
if (oldcode == -1) {
if (code >= 256)
bb_error_msg_and_die("corrupted data"); /* %ld", code); */
@@ -244,7 +246,7 @@
}
/* Generate output characters in reverse order */
- while ((long) code >= (long) 256) {
+ while (code >= 256) {
if (stackp <= &htabof(0))
bb_error_msg_and_die("corrupted data");
*--stackp = tab_suffixof(code);
@@ -285,11 +287,10 @@
}
/* Generate the new entry. */
- code = free_ent;
- if (code < maxmaxcode) {
- tab_prefixof(code) = (unsigned short) oldcode;
- tab_suffixof(code) = (unsigned char) finchar;
- free_ent = code + 1;
+ if (free_ent < maxmaxcode) {
+ tab_prefixof(free_ent) = (unsigned short) oldcode;
+ tab_suffixof(free_ent) = (unsigned char) finchar;
+ free_ent++;
}
/* Remember previous code. */