summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-02-03 20:50:20 +0100
committerDenys Vlasenko2018-02-03 20:51:12 +0100
commit86be6d5ba9df8b8237a8c3edc2a844aaa63bd559 (patch)
tree8ddd248663839ac1837963c0e4f5f0697cd789c5
parentc9ae8d770bf8a21fec962f67b759569b263c68fc (diff)
downloadbusybox-86be6d5ba9df8b8237a8c3edc2a844aaa63bd559.zip
busybox-86be6d5ba9df8b8237a8c3edc2a844aaa63bd559.tar.gz
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>
-rw-r--r--archival/libarchive/bz/blocksort.c22
-rw-r--r--archival/libarchive/bz/bzlib_private.h26
-rw-r--r--archival/libarchive/bz/compress.c6
3 files changed, 27 insertions, 27 deletions
diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c
index effaa15..7c5b6c5 100644
--- a/archival/libarchive/bz/blocksort.c
+++ b/archival/libarchive/bz/blocksort.c
@@ -1022,16 +1022,15 @@ void mainSort(EState* state)
* arr1[0 .. nblock-1] holds sorted order
*/
static NOINLINE
-void BZ2_blockSort(EState* state)
+int32_t BZ2_blockSort(EState* state)
{
/* In original bzip2 1.0.4, it's a parameter, but 30
* (which was the default) should work ok. */
enum { wfact = 30 };
unsigned i;
+ int32_t origPtr = origPtr;
- if (state->nblock < 10000) {
- fallbackSort(state);
- } else {
+ if (state->nblock >= 10000) {
/* Calculate the location for quadrant, remembering to get
* the alignment right. Assumes that &(block[0]) is at least
* 2-byte aligned -- this should be ok since block is really
@@ -1050,24 +1049,25 @@ void BZ2_blockSort(EState* state)
* of whether or not we use the main sort or fallback sort.
*/
state->budget = state->nblock * ((wfact-1) / 3);
-
mainSort(state);
- if (state->budget < 0) {
- fallbackSort(state);
- }
+ if (state->budget >= 0)
+ goto good;
}
+ fallbackSort(state);
+ good:
#if BZ_LIGHT_DEBUG
- state->origPtr = -1;
+ origPtr = -1;
#endif
for (i = 0; i < state->nblock; i++) {
if (state->ptr[i] == 0) {
- state->origPtr = i;
+ origPtr = i;
break;
}
}
- AssertH(state->origPtr != -1, 1003);
+ AssertH(origPtr != -1, 1003);
+ return origPtr;
}
diff --git a/archival/libarchive/bz/bzlib_private.h b/archival/libarchive/bz/bzlib_private.h
index fc05d0e..8b8bbe3 100644
--- a/archival/libarchive/bz/bzlib_private.h
+++ b/archival/libarchive/bz/bzlib_private.h
@@ -120,9 +120,11 @@ typedef struct EState {
/* mode this stream is in, and whether inputting */
/* or outputting data */
- int32_t mode;
-//both smallint?
- int32_t state;
+ uint8_t mode;
+ uint8_t state;
+
+ /* misc administratium */
+ uint8_t blockSize100k;
/* remembers avail_in when flush/finish requested */
/* bbox: not needed, strm->avail_in always has the same value */
@@ -130,12 +132,11 @@ typedef struct EState {
/* uint32_t avail_in_expect; */
/* for doing the block sorting */
- int32_t origPtr;
uint32_t *arr1;
uint32_t *arr2;
uint32_t *ftab;
- uint16_t* quadrant;
+ uint16_t *quadrant;
int32_t budget;
/* aliases for arr1 and arr2 */
@@ -144,10 +145,6 @@ typedef struct EState {
uint16_t *mtfv;
uint8_t *zbits;
- /* guess what */
- uint32_t *crc32table;
-//move down
-
/* run-length-encoding of the input */
uint32_t state_in_ch;
int32_t state_in_len;
@@ -156,21 +153,22 @@ typedef struct EState {
int32_t nblock;
int32_t nblockMAX;
//int32_t numZ; // index into s->zbits[], replaced by pointer:
- uint8_t *posZ;
- uint8_t *state_out_pos;
+ uint8_t *posZ;
+ uint8_t *state_out_pos;
/* the buffer for bit stream creation */
uint32_t bsBuff;
int32_t bsLive;
+ /* guess what */
+ uint32_t *crc32table;
+
/* block and combined CRCs */
uint32_t blockCRC;
uint32_t combinedCRC;
/* misc administratium */
int32_t blockNo;
- int32_t blockSize100k;
-//smallint?
/* stuff for coding the MTF values */
int32_t nMTF;
@@ -206,7 +204,7 @@ typedef struct EState {
/*-- compression. --*/
-static void
+static int32_t
BZ2_blockSort(EState*);
static void
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c
index f139324..f650767 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -665,6 +665,8 @@ void sendMTFValues(EState* s)
static
void BZ2_compressBlock(EState* s, int is_last_block)
{
+ int32_t origPtr = origPtr;
+
if (s->nblock > 0) {
BZ_FINALISE_CRC(s->blockCRC);
s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
@@ -672,7 +674,7 @@ void BZ2_compressBlock(EState* s, int is_last_block)
if (s->blockNo > 1)
s->posZ = s->zbits; // was: s->numZ = 0;
- BZ2_blockSort(s);
+ origPtr = BZ2_blockSort(s);
}
s->zbits = &((uint8_t*)s->arr2)[s->nblock];
@@ -713,7 +715,7 @@ void BZ2_compressBlock(EState* s, int is_last_block)
*/
bsW1_0(s);
- bsW(s, 24, s->origPtr);
+ bsW(s, 24, origPtr);
generateMTFValues(s);
sendMTFValues(s);
}