bzip2: optimize zPend variable code
function old new delta generateMTFValues 433 378 -55 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
fc228b48c9
commit
1cbcb02316
@ -161,7 +161,7 @@ void fallbackQSort3(uint32_t* fmap,
|
|||||||
ltLo++;
|
ltLo++;
|
||||||
unLo++;
|
unLo++;
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
if (n > 0) break;
|
if (n > 0) break;
|
||||||
unLo++;
|
unLo++;
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ void fallbackQSort3(uint32_t* fmap,
|
|||||||
mswap(fmap[unHi], fmap[gtHi]);
|
mswap(fmap[unHi], fmap[gtHi]);
|
||||||
gtHi--; unHi--;
|
gtHi--; unHi--;
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
if (n < 0) break;
|
if (n < 0) break;
|
||||||
unHi--;
|
unHi--;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ void fallbackSort(uint32_t* fmap,
|
|||||||
if (cc != cc1) {
|
if (cc != cc1) {
|
||||||
SET_BH(i);
|
SET_BH(i);
|
||||||
cc = cc1;
|
cc = cc1;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,7 +545,7 @@ uint8_t mmed3(uint8_t a, uint8_t b, uint8_t c)
|
|||||||
t = a;
|
t = a;
|
||||||
a = b;
|
a = b;
|
||||||
b = t;
|
b = t;
|
||||||
};
|
}
|
||||||
/* here b >= a */
|
/* here b >= a */
|
||||||
if (b > c) {
|
if (b > c) {
|
||||||
b = c;
|
b = c;
|
||||||
@ -638,8 +638,8 @@ void mainQSort3(uint32_t* ptr,
|
|||||||
ltLo++;
|
ltLo++;
|
||||||
unLo++;
|
unLo++;
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
if (n > 0) break;
|
if (n > 0) break;
|
||||||
unLo++;
|
unLo++;
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -651,8 +651,8 @@ void mainQSort3(uint32_t* ptr,
|
|||||||
gtHi--;
|
gtHi--;
|
||||||
unHi--;
|
unHi--;
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
if (n < 0) break;
|
if (n < 0) break;
|
||||||
unHi--;
|
unHi--;
|
||||||
}
|
}
|
||||||
if (unLo > unHi)
|
if (unLo > unHi)
|
||||||
@ -1063,7 +1063,7 @@ void BZ2_blockSort(EState* s)
|
|||||||
if (ptr[i] == 0) {
|
if (ptr[i] == 0) {
|
||||||
s->origPtr = i;
|
s->origPtr = i;
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
|
||||||
AssertH(s->origPtr != -1, 1003);
|
AssertH(s->origPtr != -1, 1003);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ void generateMTFValues(EState* s)
|
|||||||
{
|
{
|
||||||
uint8_t yy[256];
|
uint8_t yy[256];
|
||||||
int32_t i, j;
|
int32_t i, j;
|
||||||
int32_t zPend;
|
int zPend;
|
||||||
int32_t wr;
|
int32_t wr;
|
||||||
int32_t EOB;
|
int32_t EOB;
|
||||||
|
|
||||||
@ -217,6 +217,7 @@ void generateMTFValues(EState* s)
|
|||||||
if (zPend > 0) {
|
if (zPend > 0) {
|
||||||
zPend--;
|
zPend--;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
#if 0
|
||||||
if (zPend & 1) {
|
if (zPend & 1) {
|
||||||
mtfv[wr] = BZ_RUNB; wr++;
|
mtfv[wr] = BZ_RUNB; wr++;
|
||||||
s->mtfFreq[BZ_RUNB]++;
|
s->mtfFreq[BZ_RUNB]++;
|
||||||
@ -224,10 +225,18 @@ void generateMTFValues(EState* s)
|
|||||||
mtfv[wr] = BZ_RUNA; wr++;
|
mtfv[wr] = BZ_RUNA; wr++;
|
||||||
s->mtfFreq[BZ_RUNA]++;
|
s->mtfFreq[BZ_RUNA]++;
|
||||||
}
|
}
|
||||||
if (zPend < 2) break;
|
#else /* same as above, since BZ_RUNA is 0 and BZ_RUNB is 1 */
|
||||||
zPend = (uint32_t)(zPend - 2) / 2;
|
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 */
|
/* bbox: unsigned div is easier */
|
||||||
};
|
}
|
||||||
zPend = 0;
|
zPend = 0;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -244,7 +253,7 @@ void generateMTFValues(EState* s)
|
|||||||
rtmp2 = rtmp;
|
rtmp2 = rtmp;
|
||||||
rtmp = *ryy_j;
|
rtmp = *ryy_j;
|
||||||
*ryy_j = rtmp2;
|
*ryy_j = rtmp2;
|
||||||
};
|
}
|
||||||
yy[0] = rtmp;
|
yy[0] = rtmp;
|
||||||
j = ryy_j - &(yy[0]);
|
j = ryy_j - &(yy[0]);
|
||||||
mtfv[wr] = j+1;
|
mtfv[wr] = j+1;
|
||||||
@ -257,6 +266,7 @@ void generateMTFValues(EState* s)
|
|||||||
if (zPend > 0) {
|
if (zPend > 0) {
|
||||||
zPend--;
|
zPend--;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
#if 0
|
||||||
if (zPend & 1) {
|
if (zPend & 1) {
|
||||||
mtfv[wr] = BZ_RUNB;
|
mtfv[wr] = BZ_RUNB;
|
||||||
wr++;
|
wr++;
|
||||||
@ -266,12 +276,18 @@ void generateMTFValues(EState* s)
|
|||||||
wr++;
|
wr++;
|
||||||
s->mtfFreq[BZ_RUNA]++;
|
s->mtfFreq[BZ_RUNA]++;
|
||||||
}
|
}
|
||||||
if (zPend < 2)
|
#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;
|
break;
|
||||||
zPend = (uint32_t)(zPend - 2) / 2;
|
zPend = (unsigned)zPend / 2;
|
||||||
/* bbox: unsigned div is easier */
|
/* bbox: unsigned div is easier */
|
||||||
};
|
}
|
||||||
zPend = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mtfv[wr] = EOB;
|
mtfv[wr] = EOB;
|
||||||
@ -528,11 +544,11 @@ void sendMTFValues(EState* s)
|
|||||||
tmp2 = tmp;
|
tmp2 = tmp;
|
||||||
tmp = pos[j];
|
tmp = pos[j];
|
||||||
pos[j] = tmp2;
|
pos[j] = tmp2;
|
||||||
};
|
}
|
||||||
pos[0] = tmp;
|
pos[0] = tmp;
|
||||||
s->selectorMtf[i] = j;
|
s->selectorMtf[i] = j;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/*--- Assign actual codes for the tables. --*/
|
/*--- Assign actual codes for the tables. --*/
|
||||||
for (t = 0; t < nGroups; t++) {
|
for (t = 0; t < nGroups; t++) {
|
||||||
@ -595,8 +611,8 @@ void sendMTFValues(EState* s)
|
|||||||
unsigned curr = s->len[t][0];
|
unsigned curr = s->len[t][0];
|
||||||
bsW(s, 5, curr);
|
bsW(s, 5, curr);
|
||||||
for (i = 0; i < alphaSize; i++) {
|
for (i = 0; i < alphaSize; i++) {
|
||||||
while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ };
|
while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ }
|
||||||
while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ };
|
while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ }
|
||||||
bsW1_0(s);
|
bsW1_0(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ void BZ2_hbAssignCodes(int32_t *code,
|
|||||||
if (length[i] == n) {
|
if (length[i] == n) {
|
||||||
code[i] = vec;
|
code[i] = vec;
|
||||||
vec++;
|
vec++;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
vec <<= 1;
|
vec <<= 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user