[PATCH] fs: seq_file: optimize seq_pad()

From: Dmitry Voytik
Date: Wed Sep 10 2014 - 05:20:37 EST


Use seq_putc() instead of seq_printf() in seq_pad() because the
former is faster.

Signed-off-by: Dmitry Voytik <voytikd@xxxxxxxxx>
---
fs/seq_file.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/seq_file.c b/fs/seq_file.c
index 3857b72..fef338e 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -787,8 +787,10 @@ EXPORT_SYMBOL(seq_write);
void seq_pad(struct seq_file *m, char c)
{
int size = m->pad_until - m->count;
- if (size > 0)
- seq_printf(m, "%*s", size, "");
+
+ while (size-- > 0)
+ if (unlikely(seq_putc(m, ' ')))
+ return;
if (c)
seq_putc(m, c);
}
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/