diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-03 20:50:20 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-03 20:51:12 +0100 |
commit | 86be6d5ba9df8b8237a8c3edc2a844aaa63bd559 (patch) | |
tree | 8ddd248663839ac1837963c0e4f5f0697cd789c5 /archival/libarchive | |
parent | c9ae8d770bf8a21fec962f67b759569b263c68fc (diff) | |
download | busybox-w32-86be6d5ba9df8b8237a8c3edc2a844aaa63bd559.tar.gz busybox-w32-86be6d5ba9df8b8237a8c3edc2a844aaa63bd559.tar.bz2 busybox-w32-86be6d5ba9df8b8237a8c3edc2a844aaa63bd559.zip |
bzip2: move ->origPtr out of struct EState, make a few members smaller
function old new delta
BZ2_compressBlock 223 228 +5
BZ2_blockSort 85 88 +3
generateMTFValues 356 357 +1
handle_compress 355 349 -6
compressStream 538 531 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 9/-13) Total: -4 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libarchive')
-rw-r--r-- | archival/libarchive/bz/blocksort.c | 22 | ||||
-rw-r--r-- | archival/libarchive/bz/bzlib_private.h | 26 | ||||
-rw-r--r-- | archival/libarchive/bz/compress.c | 6 |
3 files changed, 27 insertions, 27 deletions
diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c index effaa152a..7c5b6c552 100644 --- a/archival/libarchive/bz/blocksort.c +++ b/archival/libarchive/bz/blocksort.c | |||
@@ -1022,16 +1022,15 @@ void mainSort(EState* state) | |||
1022 | * arr1[0 .. nblock-1] holds sorted order | 1022 | * arr1[0 .. nblock-1] holds sorted order |
1023 | */ | 1023 | */ |
1024 | static NOINLINE | 1024 | static NOINLINE |
1025 | void BZ2_blockSort(EState* state) | 1025 | int32_t BZ2_blockSort(EState* state) |
1026 | { | 1026 | { |
1027 | /* In original bzip2 1.0.4, it's a parameter, but 30 | 1027 | /* In original bzip2 1.0.4, it's a parameter, but 30 |
1028 | * (which was the default) should work ok. */ | 1028 | * (which was the default) should work ok. */ |
1029 | enum { wfact = 30 }; | 1029 | enum { wfact = 30 }; |
1030 | unsigned i; | 1030 | unsigned i; |
1031 | int32_t origPtr = origPtr; | ||
1031 | 1032 | ||
1032 | if (state->nblock < 10000) { | 1033 | if (state->nblock >= 10000) { |
1033 | fallbackSort(state); | ||
1034 | } else { | ||
1035 | /* Calculate the location for quadrant, remembering to get | 1034 | /* Calculate the location for quadrant, remembering to get |
1036 | * the alignment right. Assumes that &(block[0]) is at least | 1035 | * the alignment right. Assumes that &(block[0]) is at least |
1037 | * 2-byte aligned -- this should be ok since block is really | 1036 | * 2-byte aligned -- this should be ok since block is really |
@@ -1050,24 +1049,25 @@ void BZ2_blockSort(EState* state) | |||
1050 | * of whether or not we use the main sort or fallback sort. | 1049 | * of whether or not we use the main sort or fallback sort. |
1051 | */ | 1050 | */ |
1052 | state->budget = state->nblock * ((wfact-1) / 3); | 1051 | state->budget = state->nblock * ((wfact-1) / 3); |
1053 | |||
1054 | mainSort(state); | 1052 | mainSort(state); |
1055 | if (state->budget < 0) { | 1053 | if (state->budget >= 0) |
1056 | fallbackSort(state); | 1054 | goto good; |
1057 | } | ||
1058 | } | 1055 | } |
1056 | fallbackSort(state); | ||
1057 | good: | ||
1059 | 1058 | ||
1060 | #if BZ_LIGHT_DEBUG | 1059 | #if BZ_LIGHT_DEBUG |
1061 | state->origPtr = -1; | 1060 | origPtr = -1; |
1062 | #endif | 1061 | #endif |
1063 | for (i = 0; i < state->nblock; i++) { | 1062 | for (i = 0; i < state->nblock; i++) { |
1064 | if (state->ptr[i] == 0) { | 1063 | if (state->ptr[i] == 0) { |
1065 | state->origPtr = i; | 1064 | origPtr = i; |
1066 | break; | 1065 | break; |
1067 | } | 1066 | } |
1068 | } | 1067 | } |
1069 | 1068 | ||
1070 | AssertH(state->origPtr != -1, 1003); | 1069 | AssertH(origPtr != -1, 1003); |
1070 | return origPtr; | ||
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | 1073 | ||
diff --git a/archival/libarchive/bz/bzlib_private.h b/archival/libarchive/bz/bzlib_private.h index fc05d0ebe..8b8bbe3eb 100644 --- a/archival/libarchive/bz/bzlib_private.h +++ b/archival/libarchive/bz/bzlib_private.h | |||
@@ -120,9 +120,11 @@ typedef struct EState { | |||
120 | 120 | ||
121 | /* mode this stream is in, and whether inputting */ | 121 | /* mode this stream is in, and whether inputting */ |
122 | /* or outputting data */ | 122 | /* or outputting data */ |
123 | int32_t mode; | 123 | uint8_t mode; |
124 | //both smallint? | 124 | uint8_t state; |
125 | int32_t state; | 125 | |
126 | /* misc administratium */ | ||
127 | uint8_t blockSize100k; | ||
126 | 128 | ||
127 | /* remembers avail_in when flush/finish requested */ | 129 | /* remembers avail_in when flush/finish requested */ |
128 | /* bbox: not needed, strm->avail_in always has the same value */ | 130 | /* bbox: not needed, strm->avail_in always has the same value */ |
@@ -130,12 +132,11 @@ typedef struct EState { | |||
130 | /* uint32_t avail_in_expect; */ | 132 | /* uint32_t avail_in_expect; */ |
131 | 133 | ||
132 | /* for doing the block sorting */ | 134 | /* for doing the block sorting */ |
133 | int32_t origPtr; | ||
134 | uint32_t *arr1; | 135 | uint32_t *arr1; |
135 | uint32_t *arr2; | 136 | uint32_t *arr2; |
136 | uint32_t *ftab; | 137 | uint32_t *ftab; |
137 | 138 | ||
138 | uint16_t* quadrant; | 139 | uint16_t *quadrant; |
139 | int32_t budget; | 140 | int32_t budget; |
140 | 141 | ||
141 | /* aliases for arr1 and arr2 */ | 142 | /* aliases for arr1 and arr2 */ |
@@ -144,10 +145,6 @@ typedef struct EState { | |||
144 | uint16_t *mtfv; | 145 | uint16_t *mtfv; |
145 | uint8_t *zbits; | 146 | uint8_t *zbits; |
146 | 147 | ||
147 | /* guess what */ | ||
148 | uint32_t *crc32table; | ||
149 | //move down | ||
150 | |||
151 | /* run-length-encoding of the input */ | 148 | /* run-length-encoding of the input */ |
152 | uint32_t state_in_ch; | 149 | uint32_t state_in_ch; |
153 | int32_t state_in_len; | 150 | int32_t state_in_len; |
@@ -156,21 +153,22 @@ typedef struct EState { | |||
156 | int32_t nblock; | 153 | int32_t nblock; |
157 | int32_t nblockMAX; | 154 | int32_t nblockMAX; |
158 | //int32_t numZ; // index into s->zbits[], replaced by pointer: | 155 | //int32_t numZ; // index into s->zbits[], replaced by pointer: |
159 | uint8_t *posZ; | 156 | uint8_t *posZ; |
160 | uint8_t *state_out_pos; | 157 | uint8_t *state_out_pos; |
161 | 158 | ||
162 | /* the buffer for bit stream creation */ | 159 | /* the buffer for bit stream creation */ |
163 | uint32_t bsBuff; | 160 | uint32_t bsBuff; |
164 | int32_t bsLive; | 161 | int32_t bsLive; |
165 | 162 | ||
163 | /* guess what */ | ||
164 | uint32_t *crc32table; | ||
165 | |||
166 | /* block and combined CRCs */ | 166 | /* block and combined CRCs */ |
167 | uint32_t blockCRC; | 167 | uint32_t blockCRC; |
168 | uint32_t combinedCRC; | 168 | uint32_t combinedCRC; |
169 | 169 | ||
170 | /* misc administratium */ | 170 | /* misc administratium */ |
171 | int32_t blockNo; | 171 | int32_t blockNo; |
172 | int32_t blockSize100k; | ||
173 | //smallint? | ||
174 | 172 | ||
175 | /* stuff for coding the MTF values */ | 173 | /* stuff for coding the MTF values */ |
176 | int32_t nMTF; | 174 | int32_t nMTF; |
@@ -206,7 +204,7 @@ typedef struct EState { | |||
206 | 204 | ||
207 | /*-- compression. --*/ | 205 | /*-- compression. --*/ |
208 | 206 | ||
209 | static void | 207 | static int32_t |
210 | BZ2_blockSort(EState*); | 208 | BZ2_blockSort(EState*); |
211 | 209 | ||
212 | static void | 210 | static void |
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c index f1393242d..f65076758 100644 --- a/archival/libarchive/bz/compress.c +++ b/archival/libarchive/bz/compress.c | |||
@@ -665,6 +665,8 @@ void sendMTFValues(EState* s) | |||
665 | static | 665 | static |
666 | void BZ2_compressBlock(EState* s, int is_last_block) | 666 | void BZ2_compressBlock(EState* s, int is_last_block) |
667 | { | 667 | { |
668 | int32_t origPtr = origPtr; | ||
669 | |||
668 | if (s->nblock > 0) { | 670 | if (s->nblock > 0) { |
669 | BZ_FINALISE_CRC(s->blockCRC); | 671 | BZ_FINALISE_CRC(s->blockCRC); |
670 | s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); | 672 | s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); |
@@ -672,7 +674,7 @@ void BZ2_compressBlock(EState* s, int is_last_block) | |||
672 | if (s->blockNo > 1) | 674 | if (s->blockNo > 1) |
673 | s->posZ = s->zbits; // was: s->numZ = 0; | 675 | s->posZ = s->zbits; // was: s->numZ = 0; |
674 | 676 | ||
675 | BZ2_blockSort(s); | 677 | origPtr = BZ2_blockSort(s); |
676 | } | 678 | } |
677 | 679 | ||
678 | s->zbits = &((uint8_t*)s->arr2)[s->nblock]; | 680 | s->zbits = &((uint8_t*)s->arr2)[s->nblock]; |
@@ -713,7 +715,7 @@ void BZ2_compressBlock(EState* s, int is_last_block) | |||
713 | */ | 715 | */ |
714 | bsW1_0(s); | 716 | bsW1_0(s); |
715 | 717 | ||
716 | bsW(s, 24, s->origPtr); | 718 | bsW(s, 24, origPtr); |
717 | generateMTFValues(s); | 719 | generateMTFValues(s); |
718 | sendMTFValues(s); | 720 | sendMTFValues(s); |
719 | } | 721 | } |