Re: [PATCH v2 2/4] csum-file.h: increase hashfile buffer size
- From
Jeff King <peff@peff.net>
- Date
- May 18, 2021, 07:42 UTC
- Message-ID
- <YKNv0zeobEFgHsad@coredump.intra.peff.net>
- In-Reply-To
- <YKNtUKIHoCCOMYmn@coredump.intra.peff.net>
On Tue, May 18, 2021 at 03:31:28AM -0400, Jeff King wrote:
Show 17 quoted lines
> Does this have to use the same-size buffer? We could read and check
> smaller chunks, like:
>
> while (count > 0) {
> static unsigned char chunk[1024];
> unsigned int chunk_len = sizeof(chunk) < count ? sizeof(chunk) : count;
> ssize_t ret = read_in_full(f->check_fd, chunk, chunk_len);
>
> if (ret < 0)
> ...
> if (ret != count)
> ...
> if (memcmp(buf, chunk, chunk_len))
> ...
> buf += chunk_len;
> count -= chunk_len;
> }That should be "ret != chunk_len" in the middle conditional, of course. In case you do go this route (I typed this straight into my email, so other bugs may be lurking. But I noticed that one. :) ).
-Peff