bzip2: runningOrder[] values are always 0..255, make it uint8
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 3 Feb 2018 16:44:00 +0000 (17:44 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 3 Feb 2018 16:44:00 +0000 (17:44 +0100)
function                                             old     new   delta
mainSort                                            1171    1124     -47

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/libarchive/bz/blocksort.c
archival/libarchive/bz/bzlib_private.h

index 473244db01a49a26f7938ed0f32d9f2ef38bbb21..c2d5f15c699087d041109ebe5596a5af4ee3ea62 100644 (file)
@@ -732,7 +732,7 @@ void mainSort(EState* state,
        int32_t  i, j;
        Bool     bigDone[256];
        /* bbox: moved to EState to save stack
-       int32_t  runningOrder[256];
+       uint8_t  runningOrder[256];
        int32_t  copyStart[256];
        int32_t  copyEnd  [256];
        */
@@ -833,16 +833,15 @@ void mainSort(EState* state,
                        /*h = h / 3;*/
                        h = (h * 171) >> 9; /* bbox: fast h/3 */
                        for (i = h; i <= 255; i++) {
-                               int32_t vv;
-                               vv = runningOrder[i];
+                               unsigned vv;
+                               vv = runningOrder[i]; /* uint8[] */
                                j = i;
                                while (BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv)) {
                                        runningOrder[j] = runningOrder[j-h];
                                        j = j - h;
                                        if (j <= (h - 1))
-                                               goto zero;
+                                               break;
                                }
- zero:
                                runningOrder[j] = vv;
                        }
                } while (h != 1);
index 8e44a8e6407d5267150c21d1f9ebe65a09cd2ebd..4acaef8b878a927d81fb9af2dad81fc685aa2b8c 100644 (file)
@@ -192,7 +192,7 @@ typedef struct EState {
        int32_t  BZ2_hbMakeCodeLengths__weight[BZ_MAX_ALPHA_SIZE * 2];
        int32_t  BZ2_hbMakeCodeLengths__parent[BZ_MAX_ALPHA_SIZE * 2];
 
-       int32_t  mainSort__runningOrder[256];
+       uint8_t  mainSort__runningOrder[256];
        int32_t  mainSort__copyStart[256];
        int32_t  mainSort__copyEnd[256];
 } EState;