diff options
author | Denys Vlasenko | 2018-02-03 14:56:43 +0100 |
---|---|---|
committer | Denys Vlasenko | 2018-02-03 14:56:43 +0100 |
commit | fc228b48c9fe2c5770d2f0059bb5027ff7dd159e (patch) | |
tree | b64879573158d953add55093ccb80d8a70421c24 /archival/libarchive/bz | |
parent | feafb3423e76d3c02a1f4fc740fb3f91a211ce1c (diff) | |
download | busybox-fc228b48c9fe2c5770d2f0059bb5027ff7dd159e.zip busybox-fc228b48c9fe2c5770d2f0059bb5027ff7dd159e.tar.gz |
bzip2: have two separate "store bit 0" and "store bit 1" functions
function old new delta
sendMTFValues 2051 2085 +34
bsW1_0 - 33 +33
BZ2_compressBlock 225 223 -2
bsW1 52 - -52
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 67/-54) Total: 13 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libarchive/bz')
-rw-r--r-- | archival/libarchive/bz/compress.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c index 4d0f775..fc6af65 100644 --- a/archival/libarchive/bz/compress.c +++ b/archival/libarchive/bz/compress.c @@ -90,10 +90,23 @@ void bsW16(EState* s, uint32_t v) } /* Same with n == 1: */ static +ALWAYS_INLINE /* one callsite */ +void bsW1_1(EState* s) +{ + /* need space for only 1 bit, no need for loop freeing > 8 bits */ + if (s->bsLive >= 8) { + *s->posZ++ = (uint8_t)(s->bsBuff >> 24); + s->bsBuff <<= 8; + s->bsLive -= 8; + } + s->bsBuff |= (1 << (31 - s->bsLive)); + s->bsLive += 1; +} +static #if CONFIG_BZIP2_FAST >= 5 ALWAYS_INLINE #endif -void bsW1(EState* s, uint32_t v) +void bsW1_0(EState* s) { /* need space for only 1 bit, no need for loop freeing > 8 bits */ if (s->bsLive >= 8) { @@ -101,7 +114,7 @@ void bsW1(EState* s, uint32_t v) s->bsBuff <<= 8; s->bsLive -= 8; } - s->bsBuff |= (v << (31 - s->bsLive)); + //s->bsBuff |= (0 << (31 - s->bsLive)); s->bsLive += 1; } @@ -573,8 +586,8 @@ void sendMTFValues(EState* s) for (i = 0; i < nSelectors; i++) { unsigned j; for (j = 0; j < s->selectorMtf[i]; j++) - bsW1(s, 1); - bsW1(s, 0); + bsW1_1(s); + bsW1_0(s); } /*--- Now the coding tables. ---*/ @@ -584,7 +597,7 @@ void sendMTFValues(EState* s) for (i = 0; i < alphaSize; i++) { while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ }; while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ }; - bsW1(s, 0); + bsW1_0(s); } } @@ -698,7 +711,7 @@ void BZ2_compressBlock(EState* s, int is_last_block) * so as to maintain backwards compatibility with * older versions of bzip2. */ - bsW1(s, 0); + bsW1_0(s); bsW(s, 24, s->origPtr); generateMTFValues(s); |