summaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2020-06-18 20:22:09 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2020-06-28 11:16:05 +0200
commit10be7c55f66e08f97c15afb5c5af985094155b5a (patch)
tree7311a43bb3c8c79d3825d9da65e932f256a732d5 /inflate.c
parente40d88adc9e8180969c6c56a0deb4ec69c3ec92b (diff)
Only calculate inflate chunk size once and store it for future use for performance.
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/inflate.c b/inflate.c
index 69fc0e1..340f854 100644
--- a/inflate.c
+++ b/inflate.c
@@ -155,6 +155,7 @@ int32_t ZEXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int32_t windowBits,
state->strm = strm;
state->window = NULL;
state->mode = HEAD; /* to pass state test in inflateReset2() */
+ state->chunksize = functable.chunksize();
ret = PREFIX(inflateReset2)(strm, windowBits);
if (ret != Z_OK) {
ZFREE_STATE(strm, state);
@@ -203,10 +204,10 @@ int ZLIB_INTERNAL inflate_ensure_window(struct inflate_state *state) {
/* if it hasn't been done already, allocate space for the window */
if (state->window == NULL) {
unsigned wsize = 1U << state->wbits;
- state->window = (unsigned char *) ZALLOC_WINDOW(state->strm, wsize + functable.chunksize(), sizeof(unsigned char));
+ state->window = (unsigned char *) ZALLOC_WINDOW(state->strm, wsize + state->chunksize, sizeof(unsigned char));
if (state->window == Z_NULL)
return 1;
- memset(state->window + wsize, 0, functable.chunksize());
+ memset(state->window + wsize, 0, state->chunksize);
}
/* if window not in use yet, initialize */