summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenys Vlasenko2018-02-03 15:53:17 +0100
committerDenys Vlasenko2018-02-03 15:53:17 +0100
commit9e5662ea74ce314104904729a092a0130db6c85b (patch)
tree50626a0c4f090505ccac0b8c3962063c0d195b59 /archival
parent2cfe10a5586abe4f50994f4a0d6a01cc867b8d43 (diff)
downloadbusybox-9e5662ea74ce314104904729a092a0130db6c85b.zip
busybox-9e5662ea74ce314104904729a092a0130db6c85b.tar.gz
bzip2: reuse zPend processing code
function old new delta generateMTFValues 378 357 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival')
-rw-r--r--archival/libarchive/bz/compress.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c
index 0d08348..6260fd9 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -162,7 +162,7 @@ static NOINLINE
void generateMTFValues(EState* s)
{
uint8_t yy[256];
- int32_t i, j;
+ int i;
int zPend;
int32_t wr;
int32_t EOB;
@@ -195,16 +195,18 @@ void generateMTFValues(EState* s)
makeMaps_e(s);
EOB = s->nInUse+1;
+ wr = 0;
+ zPend = 0;
for (i = 0; i <= EOB; i++)
s->mtfFreq[i] = 0;
- wr = 0;
- zPend = 0;
for (i = 0; i < s->nInUse; i++)
yy[i] = (uint8_t) i;
for (i = 0; i < s->nblock; i++) {
- uint8_t ll_i;
+ uint8_t ll_i = ll_i; /* gcc 4.3.1 thinks it may be used w/o init */
+ int32_t j;
+
AssertD(wr <= i, "generateMTFValues(1)");
j = ptr[i] - 1;
if (j < 0)
@@ -216,6 +218,7 @@ void generateMTFValues(EState* s)
zPend++;
} else {
if (zPend > 0) {
+ process_zPend:
zPend--;
while (1) {
#if 0
@@ -238,6 +241,8 @@ void generateMTFValues(EState* s)
zPend = (unsigned)zPend / 2;
/* bbox: unsigned div is easier */
}
+ if (i < 0) /* came via "goto process_zPend"? exit */
+ goto end;
zPend = 0;
}
{
@@ -264,33 +269,10 @@ void generateMTFValues(EState* s)
}
}
- if (zPend > 0) {
- zPend--;
- while (1) {
-#if 0
- if (zPend & 1) {
- mtfv[wr] = BZ_RUNB;
- wr++;
- s->mtfFreq[BZ_RUNB]++;
- } else {
- mtfv[wr] = BZ_RUNA;
- wr++;
- s->mtfFreq[BZ_RUNA]++;
- }
-#else /* same as above, since BZ_RUNA is 0 and BZ_RUNB is 1 */
- unsigned run = zPend & 1;
- mtfv[wr] = run;
- wr++;
- s->mtfFreq[run]++;
-#endif
- zPend -= 2;
- if (zPend < 0)
- break;
- zPend = (unsigned)zPend / 2;
- /* bbox: unsigned div is easier */
- }
- }
-
+ i = -1;
+ if (zPend > 0)
+ goto process_zPend; /* "process it and come back here" */
+ end:
mtfv[wr] = EOB;
wr++;
s->mtfFreq[EOB]++;