bzip2: rewrite bit of code which depends on integer overflow
function old new delta sendMTFValues 2093 2070 -23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
83dd4ff696
commit
982c44d030
@ -297,7 +297,7 @@ void sendMTFValues(EState* s)
|
|||||||
// 200..599 = 3
|
// 200..599 = 3
|
||||||
// 600..1199 = 4
|
// 600..1199 = 4
|
||||||
// 1200..2399 = 5
|
// 1200..2399 = 5
|
||||||
// else 6
|
// 2400..99999 = 6
|
||||||
nGroups = 2;
|
nGroups = 2;
|
||||||
nGroups += (s->nMTF >= 200);
|
nGroups += (s->nMTF >= 200);
|
||||||
nGroups += (s->nMTF >= 600);
|
nGroups += (s->nMTF >= 600);
|
||||||
@ -317,12 +317,12 @@ void sendMTFValues(EState* s)
|
|||||||
unsigned tFreq, aFreq;
|
unsigned tFreq, aFreq;
|
||||||
|
|
||||||
tFreq = remF / nPart;
|
tFreq = remF / nPart;
|
||||||
ge = gs - 1; //underflows on 1st iteration
|
ge = gs;
|
||||||
aFreq = 0;
|
aFreq = 0;
|
||||||
while (aFreq < tFreq && (int)ge < (int)alphaSize-1) {
|
while (aFreq < tFreq && ge < alphaSize) {
|
||||||
ge++;
|
aFreq += s->mtfFreq[ge++];
|
||||||
aFreq += s->mtfFreq[ge];
|
|
||||||
}
|
}
|
||||||
|
ge--;
|
||||||
|
|
||||||
if (ge > gs
|
if (ge > gs
|
||||||
&& nPart != nGroups && nPart != 1
|
&& nPart != nGroups && nPart != 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user