Re: [PATCH 0/8] kernel: replace seq_puts by seq_putc
From: Al Viro
Date: Mon Apr 01 2024 - 20:58:03 EST
On Tue, Mar 26, 2024 at 09:45:14PM +0300, Maxim Moskalets wrote:
> Using seq_putc for single characters is faster and more appropriate
> than seq_puts, since only one character is passed and there is no need
> to use a more powerful and less fast function.
Could we simply do this:
static inline void seq_puts(struct seq_file *m, const char *s)
{
if (__builtin_constant_p(*s) && s[0] && !s[1])
seq_putc(m, s[0]);
else
__seq_puts(m, s);
}
IIRC, __builtin_constant_p(*s) is true when s is a string literal.
Works for recent gcc and clang...