summaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorSimon Hosie <simhos01@users.noreply.github.com>2017-03-22 10:48:39 -0700
committerHans Kristian Rosbach <hk-git@circlestorm.org>2017-03-24 22:01:48 +0100
commit67f514ab48373f535290c715356693a4bf1207d3 (patch)
tree3e02aeb98de15381163ff5fcb737bfe2f250ac00 /inflate.c
parentf4b3fa7c2466b763e3dd839d63f4b9295c6f62e8 (diff)
Inflate using wider loads and stores and a minimum of branches. (#95)
* Inflate using wider loads and stores. In inflate_fast() the output pointer always has plenty of room to write. This means that so long as the target is capable, wide un-aligned loads and stores can be used to transfer several bytes at once. When the reference distance is too short simply unroll the data a little to increase the distance. Change-Id: I59854eb25d2b1e43561c8a2afaf9175bf10cf674
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/inflate.c b/inflate.c
index 84ae6e7..8484bc3 100644
--- a/inflate.c
+++ b/inflate.c
@@ -371,9 +371,17 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy)
/* if it hasn't been done already, allocate space for the window */
if (state->window == NULL) {
+#ifdef INFFAST_CHUNKSIZE
+ unsigned wsize = 1U << state->wbits;
+ state->window = (unsigned char *) ZALLOC(strm, wsize + INFFAST_CHUNKSIZE, sizeof(unsigned char));
+ if (state->window == Z_NULL)
+ return 1;
+ memset(state->window + wsize, 0, INFFAST_CHUNKSIZE);
+#else
state->window = (unsigned char *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char));
if (state->window == NULL)
return 1;
+#endif
}
/* if window not in use yet, initialize */