diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2020-06-18 20:22:09 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-06-28 11:16:05 +0200 |
commit | 10be7c55f66e08f97c15afb5c5af985094155b5a (patch) | |
tree | 7311a43bb3c8c79d3825d9da65e932f256a732d5 /inflate.c | |
parent | e40d88adc9e8180969c6c56a0deb4ec69c3ec92b (diff) |
Only calculate inflate chunk size once and store it for future use for performance.
Diffstat (limited to 'inflate.c')
-rw-r--r-- | inflate.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 */ |