diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-26 22:50:28 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-26 22:50:28 -0700 |
commit | acfc85772a811f4c0efec835a3087b53f83f6079 (patch) | |
tree | fda6596291da38d9d3c8eaf5c521413b2b32fcd8 /gzwrite.c | |
parent | 8e0d212910a42b3f856bbaebed970e8ddc081ca3 (diff) | |
download | zlib-acfc85772a811f4c0efec835a3087b53f83f6079.tar.gz zlib-acfc85772a811f4c0efec835a3087b53f83f6079.tar.bz2 zlib-acfc85772a811f4c0efec835a3087b53f83f6079.zip |
Change gzgetc() to a macro for speed (~40% speedup in testing).
Diffstat (limited to 'gzwrite.c')
-rw-r--r-- | gzwrite.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -48,7 +48,7 @@ local int gz_init(state) | |||
48 | /* initialize write buffer */ | 48 | /* initialize write buffer */ |
49 | strm->avail_out = state->size; | 49 | strm->avail_out = state->size; |
50 | strm->next_out = state->out; | 50 | strm->next_out = state->out; |
51 | state->next = strm->next_out; | 51 | state->x.next = strm->next_out; |
52 | return 0; | 52 | return 0; |
53 | } | 53 | } |
54 | 54 | ||
@@ -75,8 +75,8 @@ local int gz_comp(state, flush) | |||
75 | doing Z_FINISH then don't write until we get to Z_STREAM_END */ | 75 | doing Z_FINISH then don't write until we get to Z_STREAM_END */ |
76 | if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && | 76 | if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && |
77 | (flush != Z_FINISH || ret == Z_STREAM_END))) { | 77 | (flush != Z_FINISH || ret == Z_STREAM_END))) { |
78 | have = (unsigned)(strm->next_out - state->next); | 78 | have = (unsigned)(strm->next_out - state->x.next); |
79 | if (have && ((got = write(state->fd, state->next, have)) < 0 || | 79 | if (have && ((got = write(state->fd, state->x.next, have)) < 0 || |
80 | (unsigned)got != have)) { | 80 | (unsigned)got != have)) { |
81 | gz_error(state, Z_ERRNO, zstrerror()); | 81 | gz_error(state, Z_ERRNO, zstrerror()); |
82 | return -1; | 82 | return -1; |
@@ -85,7 +85,7 @@ local int gz_comp(state, flush) | |||
85 | strm->avail_out = state->size; | 85 | strm->avail_out = state->size; |
86 | strm->next_out = state->out; | 86 | strm->next_out = state->out; |
87 | } | 87 | } |
88 | state->next = strm->next_out; | 88 | state->x.next = strm->next_out; |
89 | } | 89 | } |
90 | 90 | ||
91 | /* compress */ | 91 | /* compress */ |
@@ -131,7 +131,7 @@ local int gz_zero(state, len) | |||
131 | } | 131 | } |
132 | strm->avail_in = n; | 132 | strm->avail_in = n; |
133 | strm->next_in = state->in; | 133 | strm->next_in = state->in; |
134 | state->pos += n; | 134 | state->x.pos += n; |
135 | if (gz_comp(state, Z_NO_FLUSH) == -1) | 135 | if (gz_comp(state, Z_NO_FLUSH) == -1) |
136 | return -1; | 136 | return -1; |
137 | len -= n; | 137 | len -= n; |
@@ -193,7 +193,7 @@ int ZEXPORT gzwrite(file, buf, len) | |||
193 | n = len; | 193 | n = len; |
194 | memcpy(strm->next_in + strm->avail_in, buf, n); | 194 | memcpy(strm->next_in + strm->avail_in, buf, n); |
195 | strm->avail_in += n; | 195 | strm->avail_in += n; |
196 | state->pos += n; | 196 | state->x.pos += n; |
197 | buf = (char *)buf + n; | 197 | buf = (char *)buf + n; |
198 | len -= n; | 198 | len -= n; |
199 | if (len && gz_comp(state, Z_NO_FLUSH) == -1) | 199 | if (len && gz_comp(state, Z_NO_FLUSH) == -1) |
@@ -208,7 +208,7 @@ int ZEXPORT gzwrite(file, buf, len) | |||
208 | /* directly compress user buffer to file */ | 208 | /* directly compress user buffer to file */ |
209 | strm->avail_in = len; | 209 | strm->avail_in = len; |
210 | strm->next_in = (voidp)buf; | 210 | strm->next_in = (voidp)buf; |
211 | state->pos += len; | 211 | state->x.pos += len; |
212 | if (gz_comp(state, Z_NO_FLUSH) == -1) | 212 | if (gz_comp(state, Z_NO_FLUSH) == -1) |
213 | return 0; | 213 | return 0; |
214 | } | 214 | } |
@@ -249,7 +249,7 @@ int ZEXPORT gzputc(file, c) | |||
249 | if (strm->avail_in == 0) | 249 | if (strm->avail_in == 0) |
250 | strm->next_in = state->in; | 250 | strm->next_in = state->in; |
251 | strm->next_in[strm->avail_in++] = c; | 251 | strm->next_in[strm->avail_in++] = c; |
252 | state->pos++; | 252 | state->x.pos++; |
253 | return c; | 253 | return c; |
254 | } | 254 | } |
255 | 255 | ||
@@ -342,7 +342,7 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) | |||
342 | /* update buffer and position, defer compression until needed */ | 342 | /* update buffer and position, defer compression until needed */ |
343 | strm->avail_in = (unsigned)len; | 343 | strm->avail_in = (unsigned)len; |
344 | strm->next_in = state->in; | 344 | strm->next_in = state->in; |
345 | state->pos += len; | 345 | state->x.pos += len; |
346 | return len; | 346 | return len; |
347 | } | 347 | } |
348 | 348 | ||
@@ -420,7 +420,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | |||
420 | /* update buffer and position, defer compression until needed */ | 420 | /* update buffer and position, defer compression until needed */ |
421 | strm->avail_in = (unsigned)len; | 421 | strm->avail_in = (unsigned)len; |
422 | strm->next_in = state->in; | 422 | strm->next_in = state->in; |
423 | state->pos += len; | 423 | state->x.pos += len; |
424 | return len; | 424 | return len; |
425 | } | 425 | } |
426 | 426 | ||