diff options
author | Mark Wielaard <mark@klomp.org> | 2022-05-26 22:38:01 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2022-05-26 22:38:01 +0200 |
commit | 9de658d248f9fd304afa3321dd7a9de1280356ec (patch) | |
tree | bccfac651f59fb8f2f1badf7eb71e9b2fdcf6005 /compress.c | |
parent | 64d6fa68c1af46f6408f832443ce23709a2f0a66 (diff) | |
download | bzip2-9de658d248f9fd304afa3321dd7a9de1280356ec.tar.gz bzip2-9de658d248f9fd304afa3321dd7a9de1280356ec.tar.bz2 bzip2-9de658d248f9fd304afa3321dd7a9de1280356ec.zip |
Initialize the fave and cost arrays fully
We try to be smart in sendMTFValues by initializing just nGroups
number of elements instead of all BZ_N_GROUPS elements. But this means
the compiler doesn't know all elements are correctly initialized and
might warn. The arrays are really small, BZ_N_GROUPS, 6 elements. And
nGroups == BZ_N_GROUPS is the common case. So just initialize them all
always. Using a constant loop might also help the compiler to optimize
the initialization.
https://sourceware.org/bugzilla/show_bug.cgi?id=28904
Diffstat (limited to 'compress.c')
-rw-r--r-- | compress.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -321,7 +321,7 @@ void sendMTFValues ( EState* s ) | |||
321 | ---*/ | 321 | ---*/ |
322 | for (iter = 0; iter < BZ_N_ITERS; iter++) { | 322 | for (iter = 0; iter < BZ_N_ITERS; iter++) { |
323 | 323 | ||
324 | for (t = 0; t < nGroups; t++) fave[t] = 0; | 324 | for (t = 0; t < BZ_N_GROUPS; t++) fave[t] = 0; |
325 | 325 | ||
326 | for (t = 0; t < nGroups; t++) | 326 | for (t = 0; t < nGroups; t++) |
327 | for (v = 0; v < alphaSize; v++) | 327 | for (v = 0; v < alphaSize; v++) |
@@ -353,7 +353,7 @@ void sendMTFValues ( EState* s ) | |||
353 | Calculate the cost of this group as coded | 353 | Calculate the cost of this group as coded |
354 | by each of the coding tables. | 354 | by each of the coding tables. |
355 | --*/ | 355 | --*/ |
356 | for (t = 0; t < nGroups; t++) cost[t] = 0; | 356 | for (t = 0; t < BZ_N_GROUPS; t++) cost[t] = 0; |
357 | 357 | ||
358 | if (nGroups == 6 && 50 == ge-gs+1) { | 358 | if (nGroups == 6 && 50 == ge-gs+1) { |
359 | /*--- fast track the common case ---*/ | 359 | /*--- fast track the common case ---*/ |