bzip2: make locals in mainSort() saner, convert one of them from uint16 to unsigned

function                                             old     new   delta
mainSort                                            1192    1178     -14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-02-03 17:22:06 +01:00
parent aaa3818a75
commit 2109fce410

View File

@ -729,10 +729,8 @@ void mainSort(EState* state,
int32_t nblock, int32_t nblock,
int32_t* budget) int32_t* budget)
{ {
int32_t i, j, k, ss, sb; int32_t i, j;
uint8_t c1;
int32_t numQSorted; int32_t numQSorted;
uint16_t s;
Bool bigDone[256]; Bool bigDone[256];
/* bbox: moved to EState to save stack /* bbox: moved to EState to save stack
int32_t runningOrder[256]; int32_t runningOrder[256];
@ -785,6 +783,8 @@ void mainSort(EState* state,
ftab[i] = j; ftab[i] = j;
} }
{
unsigned s;
s = block[0] << 8; s = block[0] << 8;
i = nblock - 1; i = nblock - 1;
#if CONFIG_BZIP2_FAST >= 2 #if CONFIG_BZIP2_FAST >= 2
@ -813,6 +813,7 @@ void mainSort(EState* state,
ftab[s] = j; ftab[s] = j;
ptr[j] = i; ptr[j] = i;
} }
}
/* /*
* Now ftab contains the first loc of every small bucket. * Now ftab contains the first loc of every small bucket.
@ -827,7 +828,7 @@ void mainSort(EState* state,
{ {
/* bbox: was: int32_t h = 1; */ /* bbox: was: int32_t h = 1; */
/* do h = 3 * h + 1; while (h <= 256); */ /* do h = 3 * h + 1; while (h <= 256); */
uint32_t h = 364; unsigned h = 364;
do { do {
/*h = h / 3;*/ /*h = h / 3;*/
@ -855,6 +856,7 @@ void mainSort(EState* state,
numQSorted = 0; numQSorted = 0;
for (i = 0; /*i <= 255*/; i++) { for (i = 0; /*i <= 255*/; i++) {
int32_t ss;
/* /*
* Process big buckets, starting with the least full. * Process big buckets, starting with the least full.
@ -874,6 +876,7 @@ void mainSort(EState* state,
*/ */
for (j = 0; j <= 255; j++) { for (j = 0; j <= 255; j++) {
if (j != ss) { if (j != ss) {
int32_t sb;
sb = (ss << 8) + j; sb = (ss << 8) + j;
if (!(ftab[sb] & SETMASK)) { if (!(ftab[sb] & SETMASK)) {
int32_t lo = ftab[sb] & CLEARMASK; int32_t lo = ftab[sb] & CLEARMASK;
@ -906,6 +909,8 @@ void mainSort(EState* state,
copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1; copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1;
} }
for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) { for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) {
unsigned c1;
int32_t k;
k = ptr[j] - 1; k = ptr[j] - 1;
if (k < 0) if (k < 0)
k += nblock; k += nblock;
@ -914,6 +919,8 @@ void mainSort(EState* state,
ptr[copyStart[c1]++] = k; ptr[copyStart[c1]++] = k;
} }
for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
unsigned c1;
int32_t k;
k = ptr[j]-1; k = ptr[j]-1;
if (k < 0) if (k < 0)
k += nblock; k += nblock;