aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-08-29 15:32:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-08-29 15:32:42 +0200
commit6d3da732a5d07b4c2f05f4f96df57b7618d0448f (patch)
tree538c3f564a719a39de4301235457f47137658674
parent49a2e484b5bd3f6343e55bfed823d3ca6bd5d45a (diff)
downloadbusybox-w32-6d3da732a5d07b4c2f05f4f96df57b7618d0448f.tar.gz
busybox-w32-6d3da732a5d07b4c2f05f4f96df57b7618d0448f.tar.bz2
busybox-w32-6d3da732a5d07b4c2f05f4f96df57b7618d0448f.zip
bzip: make ftab[] and crc32table[] member arrays of EState, do not allocate
function old new delta mainSort 941 986 +45 fallbackSort 1471 1469 -2 add_pair_to_block 194 188 -6 compressStream 543 515 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 45/-36) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/libarchive/bz/bzlib.c7
-rw-r--r--archival/libarchive/bz/bzlib_private.h11
2 files changed, 10 insertions, 8 deletions
diff --git a/archival/libarchive/bz/bzlib.c b/archival/libarchive/bz/bzlib.c
index 9af2f026d..ef19ae165 100644
--- a/archival/libarchive/bz/bzlib.c
+++ b/archival/libarchive/bz/bzlib.c
@@ -99,9 +99,8 @@ void BZ2_bzCompressInit(bz_stream *strm, int blockSize100k)
99 s->ptr = (uint32_t*)s->arr1; 99 s->ptr = (uint32_t*)s->arr1;
100 s->arr2 = xmalloc((n + BZ_N_OVERSHOOT) * sizeof(uint32_t)); 100 s->arr2 = xmalloc((n + BZ_N_OVERSHOOT) * sizeof(uint32_t));
101 s->block = (uint8_t*)s->arr2; 101 s->block = (uint8_t*)s->arr2;
102 s->ftab = xmalloc(65537 * sizeof(uint32_t));
103 102
104 s->crc32table = crc32_filltable(NULL, 1); 103 crc32_filltable(s->crc32table, 1);
105 104
106 s->state = BZ_S_INPUT; 105 s->state = BZ_S_INPUT;
107 s->mode = BZ_M_RUNNING; 106 s->mode = BZ_M_RUNNING;
@@ -369,8 +368,8 @@ void BZ2_bzCompressEnd(bz_stream *strm)
369 s = strm->state; 368 s = strm->state;
370 free(s->arr1); 369 free(s->arr1);
371 free(s->arr2); 370 free(s->arr2);
372 free(s->ftab); 371 //free(s->ftab); // made it array member of s
373 free(s->crc32table); 372 //free(s->crc32table); // ditto
374 free(s); 373 free(s);
375} 374}
376 375
diff --git a/archival/libarchive/bz/bzlib_private.h b/archival/libarchive/bz/bzlib_private.h
index ea0f29b7c..650444a5c 100644
--- a/archival/libarchive/bz/bzlib_private.h
+++ b/archival/libarchive/bz/bzlib_private.h
@@ -134,7 +134,7 @@ typedef struct EState {
134 /* for doing the block sorting */ 134 /* for doing the block sorting */
135 uint32_t *arr1; 135 uint32_t *arr1;
136 uint32_t *arr2; 136 uint32_t *arr2;
137 uint32_t *ftab; 137 //uint32_t *ftab; //moved into this struct, see below
138 138
139 uint16_t *quadrant; 139 uint16_t *quadrant;
140 int32_t budget; 140 int32_t budget;
@@ -160,9 +160,6 @@ typedef struct EState {
160 uint32_t bsBuff; 160 uint32_t bsBuff;
161 int32_t bsLive; 161 int32_t bsLive;
162 162
163 /* guess what */
164 uint32_t *crc32table;
165
166 /* block and combined CRCs */ 163 /* block and combined CRCs */
167 uint32_t blockCRC; 164 uint32_t blockCRC;
168 uint32_t combinedCRC; 165 uint32_t combinedCRC;
@@ -185,6 +182,12 @@ typedef struct EState {
185 182
186 uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; 183 uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
187 184
185 /* guess what */
186 uint32_t crc32table[256];
187
188 /* for doing the block sorting */
189 uint32_t ftab[65537];
190
188 /* stack-saving measures: these can be local, but they are too big */ 191 /* stack-saving measures: these can be local, but they are too big */
189 int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; 192 int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
190 int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; 193 int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];