On 28/02/2026 06:26, Collin Funk wrote:
This results in a noticeable increase in performance:$ yes /dev/null | head -n 10000000 | tr '\n' '\0' \ | time --format=%E ./src/du-prev -l --files0-from=- > /dev/null 0:20.40 $ yes /dev/null | head -n 10000000 | tr '\n' '\0' \ | time --format=%E ./src/du -l --files0-from=- > /dev/null 0:16.57 * src/du.c (print_size): Prefer putchar and fputs which may be unlocked unlike printf. Prefer ferror to fflush. --- src/du.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/du.c b/src/du.c index 8243ef1ac..a41ece904 100644 --- a/src/du.c +++ b/src/du.c @@ -464,10 +464,11 @@ print_size (const struct duinfo *pdui, char const *string) fputs (timetostr (pdui->tmax.tv_sec, buf), stdout); } } - printf ("\t%s%c", string, opt_nul_terminate_output ? '\0' : '\n'); - if (fflush (stdout) != 0) + putchar ('\t'); + fputs (string, stdout); + putchar (opt_nul_terminate_output ? '\0' : '\n'); + if (ferror (stdout)) write_error (); - }/* Fill the di_mnt set with local mount point dev/ino pairs. */
nice. cheers, Padraig
