diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-14 07:49:48 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-14 07:49:48 +0000 |
commit | 6a9154b6f649341870bc06e896d2fe7235a4aef9 (patch) | |
tree | b80d1603d370838166ada58b42cd6e0b8c7c6970 /archival/bz/compress.c | |
parent | 3f5fdc7572d932f33f81029956b87230c9b05182 (diff) | |
download | busybox-w32-6a9154b6f649341870bc06e896d2fe7235a4aef9.tar.gz busybox-w32-6a9154b6f649341870bc06e896d2fe7235a4aef9.tar.bz2 busybox-w32-6a9154b6f649341870bc06e896d2fe7235a4aef9.zip |
bzip2: eliminate some divisions
Diffstat (limited to 'archival/bz/compress.c')
-rw-r--r-- | archival/bz/compress.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/archival/bz/compress.c b/archival/bz/compress.c index 3e2fbd867..724474e2d 100644 --- a/archival/bz/compress.c +++ b/archival/bz/compress.c | |||
@@ -186,7 +186,8 @@ void generateMTFValues(EState* s) | |||
186 | s->mtfFreq[BZ_RUNA]++; | 186 | s->mtfFreq[BZ_RUNA]++; |
187 | } | 187 | } |
188 | if (zPend < 2) break; | 188 | if (zPend < 2) break; |
189 | zPend = (zPend - 2) / 2; | 189 | zPend = (uint32_t)(zPend - 2) / 2; |
190 | /* bbox: unsigned div is easier */ | ||
190 | }; | 191 | }; |
191 | zPend = 0; | 192 | zPend = 0; |
192 | } | 193 | } |
@@ -219,15 +220,18 @@ void generateMTFValues(EState* s) | |||
219 | zPend--; | 220 | zPend--; |
220 | while (1) { | 221 | while (1) { |
221 | if (zPend & 1) { | 222 | if (zPend & 1) { |
222 | mtfv[wr] = BZ_RUNB; wr++; | 223 | mtfv[wr] = BZ_RUNB; |
224 | wr++; | ||
223 | s->mtfFreq[BZ_RUNB]++; | 225 | s->mtfFreq[BZ_RUNB]++; |
224 | } else { | 226 | } else { |
225 | mtfv[wr] = BZ_RUNA; wr++; | 227 | mtfv[wr] = BZ_RUNA; |
228 | wr++; | ||
226 | s->mtfFreq[BZ_RUNA]++; | 229 | s->mtfFreq[BZ_RUNA]++; |
227 | } | 230 | } |
228 | if (zPend < 2) | 231 | if (zPend < 2) |
229 | break; | 232 | break; |
230 | zPend = (zPend - 2) / 2; | 233 | zPend = (uint32_t)(zPend - 2) / 2; |
234 | /* bbox: unsigned div is easier */ | ||
231 | }; | 235 | }; |
232 | zPend = 0; | 236 | zPend = 0; |
233 | } | 237 | } |
@@ -288,7 +292,7 @@ void sendMTFValues(EState* s) | |||
288 | gs = 0; | 292 | gs = 0; |
289 | while (nPart > 0) { | 293 | while (nPart > 0) { |
290 | tFreq = remF / nPart; | 294 | tFreq = remF / nPart; |
291 | ge = gs-1; | 295 | ge = gs - 1; |
292 | aFreq = 0; | 296 | aFreq = 0; |
293 | while (aFreq < tFreq && ge < alphaSize-1) { | 297 | while (aFreq < tFreq && ge < alphaSize-1) { |
294 | ge++; | 298 | ge++; |
@@ -297,7 +301,7 @@ void sendMTFValues(EState* s) | |||
297 | 301 | ||
298 | if (ge > gs | 302 | if (ge > gs |
299 | && nPart != nGroups && nPart != 1 | 303 | && nPart != nGroups && nPart != 1 |
300 | && ((nGroups - nPart) % 2 == 1) | 304 | && ((nGroups - nPart) % 2 == 1) /* bbox: can this be replaced by x & 1? */ |
301 | ) { | 305 | ) { |
302 | aFreq -= s->mtfFreq[ge]; | 306 | aFreq -= s->mtfFreq[ge]; |
303 | ge--; | 307 | ge--; |
@@ -310,7 +314,7 @@ void sendMTFValues(EState* s) | |||
310 | s->len[nPart-1][v] = BZ_GREATER_ICOST; | 314 | s->len[nPart-1][v] = BZ_GREATER_ICOST; |
311 | 315 | ||
312 | nPart--; | 316 | nPart--; |
313 | gs = ge+1; | 317 | gs = ge + 1; |
314 | remF -= aFreq; | 318 | remF -= aFreq; |
315 | } | 319 | } |
316 | } | 320 | } |
@@ -414,7 +418,7 @@ void sendMTFValues(EState* s) | |||
414 | /* | 418 | /* |
415 | * Increment the symbol frequencies for the selected table. | 419 | * Increment the symbol frequencies for the selected table. |
416 | */ | 420 | */ |
417 | /* 1% faster compress. +800 bytes */ | 421 | /* 1% faster compress. +800 bytes */ |
418 | #if CONFIG_BZIP2_FEATURE_SPEED >= 4 | 422 | #if CONFIG_BZIP2_FEATURE_SPEED >= 4 |
419 | if (nGroups == 6 && 50 == ge-gs+1) { | 423 | if (nGroups == 6 && 50 == ge-gs+1) { |
420 | /*--- fast track the common case ---*/ | 424 | /*--- fast track the common case ---*/ |