Skip to content

Commit 8642feb

Browse files
committed
zstream: use UINT_MAX sized chunks
Instead of paging to zlib in INT_MAX sized chunks, we can give it as many as UINT_MAX bytes at a time. zlib doesn't care how big a buffer we give it, this simply results in fewer calls into zlib.
1 parent ddefea7 commit 8642feb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/zstream.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
103103
/* set up in data */
104104
zstream->z.next_in = (Bytef *)zstream->in;
105105
zstream->z.avail_in = (uInt)zstream->in_len;
106+
106107
if ((size_t)zstream->z.avail_in != zstream->in_len) {
107-
zstream->z.avail_in = INT_MAX;
108+
zstream->z.avail_in = UINT_MAX;
108109
zflush = Z_NO_FLUSH;
109110
} else {
110111
zflush = Z_FINISH;
@@ -115,7 +116,7 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
115116
zstream->z.next_out = out;
116117
zstream->z.avail_out = (uInt)out_remain;
117118
if ((size_t)zstream->z.avail_out != out_remain)
118-
zstream->z.avail_out = INT_MAX;
119+
zstream->z.avail_out = UINT_MAX;
119120
out_queued = (size_t)zstream->z.avail_out;
120121

121122
/* compress next chunk */

0 commit comments

Comments
 (0)