linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Christophe JAILLET' <christophe.jaillet@wanadoo.fr>,
	'Al Viro' <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: RE: [PATCH] seq_file: Optimize seq_puts()
Date: Sun, 21 Apr 2024 17:21:32 +0000	[thread overview]
Message-ID: <e3b8b5d4c43d4d6d88bc8e6d516c1d41@AcuMS.aculab.com> (raw)
In-Reply-To: <5e5cde3e-f3ad-4a9b-bc02-1c473affdcb1@wanadoo.fr>

From: Christophe JAILLET
> Sent: 19 April 2024 21:38
...
> > I did wonder about checking sizeof(s) <= 2 in the #define version.
> 
> git grep seq_puts.*\"[^\\].\" | wc -l
> 77
> 
> What would you do in this case?
> 2 seq_putc() in order to save a memcpy(..., 2), that's it?
> 
> It would also slightly change the behaviour, as only the 1st char could
> be added. Actually, it is all or nothing.

Doing:
	if (sizeof(str) == 2 && str[0])
		seq_putc(m. str[0]);
	else
		__seq_puts(m, str);
Would pick up loops that do:
	char sep[2] = "";

	for (;; sep[0] = ',') {
		...
		seq_puts(m, sep);
		...
	}
as well as seq_puts(m, "x");

Whether that is worthwhile is another matter.
But it might be used.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2024-04-21 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 13:29 [PATCH] seq_file: Optimize seq_puts() Christophe JAILLET
2024-04-15 20:47 ` Christophe JAILLET
2024-04-15 21:00   ` Al Viro
2024-04-16 20:56     ` David Laight
2024-04-17  1:04       ` Al Viro
2024-04-19 18:59         ` Christophe JAILLET
2024-04-19 20:38       ` Christophe JAILLET
2024-04-19 21:32         ` Al Viro
2024-04-21 17:21         ` David Laight [this message]
2024-04-17  7:53   ` Rasmus Villemoes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3b8b5d4c43d4d6d88bc8e6d516c1d41@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=brauner@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=jack@suse.cz \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).