aboutsummaryrefslogtreecommitdiff
path: root/zlib.h
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-26 22:50:28 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-26 22:50:28 -0700
commitacfc85772a811f4c0efec835a3087b53f83f6079 (patch)
treefda6596291da38d9d3c8eaf5c521413b2b32fcd8 /zlib.h
parent8e0d212910a42b3f856bbaebed970e8ddc081ca3 (diff)
downloadzlib-acfc85772a811f4c0efec835a3087b53f83f6079.tar.gz
zlib-acfc85772a811f4c0efec835a3087b53f83f6079.tar.bz2
zlib-acfc85772a811f4c0efec835a3087b53f83f6079.zip
Change gzgetc() to a macro for speed (~40% speedup in testing).
Diffstat (limited to 'zlib.h')
-rw-r--r--zlib.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/zlib.h b/zlib.h
index 4c505b9..d358a62 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1186,7 +1186,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
1186 wrapper, documented in RFC 1952, wrapped around a deflate stream. 1186 wrapper, documented in RFC 1952, wrapped around a deflate stream.
1187*/ 1187*/
1188 1188
1189typedef voidp gzFile; /* opaque gzip file descriptor */ 1189typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
1190 1190
1191/* 1191/*
1192ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); 1192ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
@@ -1322,10 +1322,13 @@ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
1322 returns the value that was written, or -1 in case of error. 1322 returns the value that was written, or -1 in case of error.
1323*/ 1323*/
1324 1324
1325ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
1326/* 1325/*
1326ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
1327 Reads one byte from the compressed file. gzgetc returns this byte or -1 1327 Reads one byte from the compressed file. gzgetc returns this byte or -1
1328 in case of end of file or error. 1328 in case of end of file or error. This is implemented as a macro for speed.
1329 As such, it does not do all of the checking the other functions do. I.e.
1330 it does not check to see if file is NULL, nor whether the structure file
1331 points to has been clobbered or not.
1329*/ 1332*/
1330 1333
1331ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); 1334ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
@@ -1583,6 +1586,22 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
1583 inflateBackInit_((strm), (windowBits), (window), \ 1586 inflateBackInit_((strm), (windowBits), (window), \
1584 ZLIB_VERSION, (int)sizeof(z_stream)) 1587 ZLIB_VERSION, (int)sizeof(z_stream))
1585 1588
1589/* gzgetc() macro and its supporting function and exposed data structure. Note
1590 * that the real internal state is much larger than the exposed structure.
1591 * This abbreviated structure exposes just enough for the gzgetc() macro. The
1592 * user should not mess with these exposed elements, since their names or
1593 * behavior could change in the future, perhaps even capriciously. They can
1594 * only be used by the gzgetc() macro. You have been warned.
1595 */
1596struct gzFile_s {
1597 unsigned have;
1598 unsigned char *next;
1599 z_off64_t pos;
1600};
1601ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
1602#define gzgetc(g) \
1603 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc_(g))
1604
1586/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or 1605/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
1587 * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if 1606 * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
1588 * both are true, the application gets the *64 functions, and the regular 1607 * both are true, the application gets the *64 functions, and the regular