aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-02-03 15:53:17 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-02-03 15:53:17 +0100
commit9e5662ea74ce314104904729a092a0130db6c85b (patch)
tree50626a0c4f090505ccac0b8c3962063c0d195b59
parent2cfe10a5586abe4f50994f4a0d6a01cc867b8d43 (diff)
downloadbusybox-w32-9e5662ea74ce314104904729a092a0130db6c85b.tar.gz
busybox-w32-9e5662ea74ce314104904729a092a0130db6c85b.tar.bz2
busybox-w32-9e5662ea74ce314104904729a092a0130db6c85b.zip
bzip2: reuse zPend processing code
function old new delta generateMTFValues 378 357 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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 0d083486b..6260fd94c 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -162,7 +162,7 @@ static NOINLINE
162void generateMTFValues(EState* s) 162void generateMTFValues(EState* s)
163{ 163{
164 uint8_t yy[256]; 164 uint8_t yy[256];
165 int32_t i, j; 165 int i;
166 int zPend; 166 int zPend;
167 int32_t wr; 167 int32_t wr;
168 int32_t EOB; 168 int32_t EOB;
@@ -195,16 +195,18 @@ void generateMTFValues(EState* s)
195 makeMaps_e(s); 195 makeMaps_e(s);
196 EOB = s->nInUse+1; 196 EOB = s->nInUse+1;
197 197
198 wr = 0;
199 zPend = 0;
198 for (i = 0; i <= EOB; i++) 200 for (i = 0; i <= EOB; i++)
199 s->mtfFreq[i] = 0; 201 s->mtfFreq[i] = 0;
200 202
201 wr = 0;
202 zPend = 0;
203 for (i = 0; i < s->nInUse; i++) 203 for (i = 0; i < s->nInUse; i++)
204 yy[i] = (uint8_t) i; 204 yy[i] = (uint8_t) i;
205 205
206 for (i = 0; i < s->nblock; i++) { 206 for (i = 0; i < s->nblock; i++) {
207 uint8_t ll_i; 207 uint8_t ll_i = ll_i; /* gcc 4.3.1 thinks it may be used w/o init */
208 int32_t j;
209
208 AssertD(wr <= i, "generateMTFValues(1)"); 210 AssertD(wr <= i, "generateMTFValues(1)");
209 j = ptr[i] - 1; 211 j = ptr[i] - 1;
210 if (j < 0) 212 if (j < 0)
@@ -216,6 +218,7 @@ void generateMTFValues(EState* s)
216 zPend++; 218 zPend++;
217 } else { 219 } else {
218 if (zPend > 0) { 220 if (zPend > 0) {
221 process_zPend:
219 zPend--; 222 zPend--;
220 while (1) { 223 while (1) {
221#if 0 224#if 0
@@ -238,6 +241,8 @@ void generateMTFValues(EState* s)
238 zPend = (unsigned)zPend / 2; 241 zPend = (unsigned)zPend / 2;
239 /* bbox: unsigned div is easier */ 242 /* bbox: unsigned div is easier */
240 } 243 }
244 if (i < 0) /* came via "goto process_zPend"? exit */
245 goto end;
241 zPend = 0; 246 zPend = 0;
242 } 247 }
243 { 248 {
@@ -264,33 +269,10 @@ void generateMTFValues(EState* s)
264 } 269 }
265 } 270 }
266 271
267 if (zPend > 0) { 272 i = -1;
268 zPend--; 273 if (zPend > 0)
269 while (1) { 274 goto process_zPend; /* "process it and come back here" */
270#if 0 275 end:
271 if (zPend & 1) {
272 mtfv[wr] = BZ_RUNB;
273 wr++;
274 s->mtfFreq[BZ_RUNB]++;
275 } else {
276 mtfv[wr] = BZ_RUNA;
277 wr++;
278 s->mtfFreq[BZ_RUNA]++;
279 }
280#else /* same as above, since BZ_RUNA is 0 and BZ_RUNB is 1 */
281 unsigned run = zPend & 1;
282 mtfv[wr] = run;
283 wr++;
284 s->mtfFreq[run]++;
285#endif
286 zPend -= 2;
287 if (zPend < 0)
288 break;
289 zPend = (unsigned)zPend / 2;
290 /* bbox: unsigned div is easier */
291 }
292 }
293
294 mtfv[wr] = EOB; 276 mtfv[wr] = EOB;
295 wr++; 277 wr++;
296 s->mtfFreq[EOB]++; 278 s->mtfFreq[EOB]++;