Re: [PATCH] strbuf_write: omit system call when length is zero
- From
Stefan Beller <sbeller@google.com>
- Date
- Feb 26, 2016, 17:09 UTC
- Message-ID
- <CAGZ79kZYqf3K5mR0_1eeQHO-n675BRfEQvC_-YCb+gOPTJ5xXA@mail.gmail.com>
- In-Reply-To
- <xmqqy4a8l04f.fsf@gitster.mtv.corp.google.com>
On Thu, Feb 25, 2016 at 5:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes: > >> On Fri, Feb 26, 2016 at 5:34 AM, Stefan Beller <sbeller@google.com> wrote: >>> In case the length of the buffer is zero, we do not need to call the >>> fwrite system call as a performance improvement. >> >> fwrite is a libc call, not system call. Are you sure it always calls >> write() (assuming buffering is off)? > > I do not think so, but I suspect that the patch misstates its > rationale (I said I get uncomfortable every time I see a function > that takes size and nelem separately used by a caller that can > potentially pass nleme=0, when I wondered it it is OK that no caller > of this funtion checks its return value). >
This is exactly what happened. I assumed fwrite would be a system call eventually.