From: Stefan Beller Date: Fri, 26 Feb 2016 17:09:50 GMT Subject: Re: [PATCH] strbuf_write: omit system call when length is zero Message-ID: In-Reply-To: On Thu, Feb 25, 2016 at 5:40 PM, Junio C Hamano wrote: > Duy Nguyen writes: > >> On Fri, Feb 26, 2016 at 5:34 AM, Stefan Beller 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.