Re: [hackers] [sbase][PATCH] head: remove useless buffering

From: NRK <nrk_AT_disroot.org>
Date: Wed, 6 Mar 2024 02:29:25 +0000

> + while (i < n && (c = fgetc(fp)) != EOF) {
> + if (fputc(c, stdout) == EOF)

I don't see this as an improvement. Each one of the fgetc and fputc are
going to go through a mutex lock (along with possibly going through a
call into a dynamic function).

I think the current solution with getline is fine in practice. It's
unlikely for a line to be too big to malloc.

I think a more worthwhile improvement - to head(1) and a couple other
utils - would be to add nul-delim support via `-z`. It's required in
order to correctly deal with all valid filenames in a shell script. And
AFAIK many of the `-z` like option are currently accepted into the next
POSIX draft.

- NRK
Received on Wed Mar 06 2024 - 03:29:25 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 06 2024 - 03:36:38 CET