diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2017-12-10 17:23:44 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2017-12-20 16:08:03 +0000 |
commit | 8642feba7429ac2941a879a0870a84a83a3664cd (patch) | |
tree | 218af8bd2fb58438f0cd88f45e0ea3ad3b9e42cd /src | |
parent | ddefea750adcde06867b49d251760844540919fe (diff) | |
download | libgit2-8642feba7429ac2941a879a0870a84a83a3664cd.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/zstream.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/zstream.c b/src/zstream.c index 1c9d506b1..963c9a344 100644 --- a/src/zstream.c +++ b/src/zstream.c @@ -103,8 +103,9 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream) /* set up in data */ zstream->z.next_in = (Bytef *)zstream->in; zstream->z.avail_in = (uInt)zstream->in_len; + if ((size_t)zstream->z.avail_in != zstream->in_len) { - zstream->z.avail_in = INT_MAX; + zstream->z.avail_in = UINT_MAX; zflush = Z_NO_FLUSH; } else { zflush = Z_FINISH; @@ -115,7 +116,7 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream) zstream->z.next_out = out; zstream->z.avail_out = (uInt)out_remain; if ((size_t)zstream->z.avail_out != out_remain) - zstream->z.avail_out = INT_MAX; + zstream->z.avail_out = UINT_MAX; out_queued = (size_t)zstream->z.avail_out; /* compress next chunk */ |