aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive/bz
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-02-03 04:43:46 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-02-03 04:43:46 +0100
commitfeafb3423e76d3c02a1f4fc740fb3f91a211ce1c (patch)
treedf527b15a448e1f1bb9f463de828f0528f022df8 /archival/libarchive/bz
parent982c44d030dbb9eec3ae6522b12838c5f0754070 (diff)
downloadbusybox-w32-feafb3423e76d3c02a1f4fc740fb3f91a211ce1c.tar.gz
busybox-w32-feafb3423e76d3c02a1f4fc740fb3f91a211ce1c.tar.bz2
busybox-w32-feafb3423e76d3c02a1f4fc740fb3f91a211ce1c.zip
bzip2: ~1% speedup by special-casing "store 1 bit" function
function old new delta bsW1 - 52 +52 BZ2_compressBlock 230 225 -5 BZ2_blockSort 125 118 -7 sendMTFValues 2070 2051 -19 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 52/-31) Total: 21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libarchive/bz')
-rw-r--r--archival/libarchive/bz/blocksort.c2
-rw-r--r--archival/libarchive/bz/bzlib.c2
-rw-r--r--archival/libarchive/bz/compress.c24
3 files changed, 23 insertions, 5 deletions
diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c
index e600cb7a7..a3b099f4b 100644
--- a/archival/libarchive/bz/blocksort.c
+++ b/archival/libarchive/bz/blocksort.c
@@ -1056,7 +1056,9 @@ void BZ2_blockSort(EState* s)
1056 } 1056 }
1057 } 1057 }
1058 1058
1059#if BZ_LIGHT_DEBUG
1059 s->origPtr = -1; 1060 s->origPtr = -1;
1061#endif
1060 for (i = 0; i < s->nblock; i++) 1062 for (i = 0; i < s->nblock; i++)
1061 if (ptr[i] == 0) { 1063 if (ptr[i] == 0) {
1062 s->origPtr = i; 1064 s->origPtr = i;
diff --git a/archival/libarchive/bz/bzlib.c b/archival/libarchive/bz/bzlib.c
index 3572474f4..ef98bb213 100644
--- a/archival/libarchive/bz/bzlib.c
+++ b/archival/libarchive/bz/bzlib.c
@@ -55,7 +55,7 @@ void prepare_new_block(EState* s)
55{ 55{
56 int i; 56 int i;
57 s->nblock = 0; 57 s->nblock = 0;
58 //indexes inot s->zbits[], initialzation moved to init of s->zbits 58 //indexes into s->zbits[], initialzation moved to init of s->zbits
59 //s->posZ = s->zbits; // was: s->numZ = 0; 59 //s->posZ = s->zbits; // was: s->numZ = 0;
60 //s->state_out_pos = s->zbits; 60 //s->state_out_pos = s->zbits;
61 BZ_INITIALISE_CRC(s->blockCRC); 61 BZ_INITIALISE_CRC(s->blockCRC);
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c
index 271982cf2..4d0f77592 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -88,6 +88,22 @@ void bsW16(EState* s, uint32_t v)
88 s->bsBuff |= (v << (16 - s->bsLive)); 88 s->bsBuff |= (v << (16 - s->bsLive));
89 s->bsLive += 16; 89 s->bsLive += 16;
90} 90}
91/* Same with n == 1: */
92static
93#if CONFIG_BZIP2_FAST >= 5
94ALWAYS_INLINE
95#endif
96void bsW1(EState* s, uint32_t v)
97{
98 /* need space for only 1 bit, no need for loop freeing > 8 bits */
99 if (s->bsLive >= 8) {
100 *s->posZ++ = (uint8_t)(s->bsBuff >> 24);
101 s->bsBuff <<= 8;
102 s->bsLive -= 8;
103 }
104 s->bsBuff |= (v << (31 - s->bsLive));
105 s->bsLive += 1;
106}
91 107
92 108
93/*---------------------------------------------------*/ 109/*---------------------------------------------------*/
@@ -557,8 +573,8 @@ void sendMTFValues(EState* s)
557 for (i = 0; i < nSelectors; i++) { 573 for (i = 0; i < nSelectors; i++) {
558 unsigned j; 574 unsigned j;
559 for (j = 0; j < s->selectorMtf[i]; j++) 575 for (j = 0; j < s->selectorMtf[i]; j++)
560 bsW(s, 1, 1); 576 bsW1(s, 1);
561 bsW(s, 1, 0); 577 bsW1(s, 0);
562 } 578 }
563 579
564 /*--- Now the coding tables. ---*/ 580 /*--- Now the coding tables. ---*/
@@ -568,7 +584,7 @@ void sendMTFValues(EState* s)
568 for (i = 0; i < alphaSize; i++) { 584 for (i = 0; i < alphaSize; i++) {
569 while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ }; 585 while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ };
570 while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ }; 586 while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ };
571 bsW(s, 1, 0); 587 bsW1(s, 0);
572 } 588 }
573 } 589 }
574 590
@@ -682,7 +698,7 @@ void BZ2_compressBlock(EState* s, int is_last_block)
682 * so as to maintain backwards compatibility with 698 * so as to maintain backwards compatibility with
683 * older versions of bzip2. 699 * older versions of bzip2.
684 */ 700 */
685 bsW(s, 1, 0); 701 bsW1(s, 0);
686 702
687 bsW(s, 24, s->origPtr); 703 bsW(s, 24, s->origPtr);
688 generateMTFValues(s); 704 generateMTFValues(s);