coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fold: add the --characters option


From: Collin Funk
Subject: Re: fold: add the --characters option
Date: Sun, 24 Aug 2025 12:15:10 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

PƔdraig Brady <P@draigBrady.com> writes:

> I don't think getline() is a generic enough interface,
> especially for a utility used to introduce new lines.
>
> Consider for example you want 80x10 lines of "y",
> you could do this previously with:
>
>   $ yes | tr -d '\n' | fold -w 80 | head -n 10
>
> While now fold will just consume all of memory.
> Instead you might fread() to an IO_BUFSIZE buffer?

Good point.

Using fread is also faster since it doesn't check for the delimiter upon
reading a character, and doesn't need to lock the stream each call
(since we use fread_unlocked).

Will push the attached in a bit.

Collin

Attachment: 0001-fold-use-fread-instead-of-getline.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]