From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 1/3] column: use variable lenght printf field width to wprint blanks
Date: Sun, 4 Aug 2013 00:15:19 +0100 [thread overview]
Message-ID: <1375571721-30008-1-git-send-email-kerolasa@iki.fi> (raw)
This makes program to run a little faster. My test input show about 20%
speed improvement.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
text-utils/column.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/text-utils/column.c b/text-utils/column.c
index 2084ba6..2430ede 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -308,7 +308,7 @@ wchar_t *local_wcstok(wchar_t * p, const wchar_t * separator, int greedy,
static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy, wchar_t *colsep)
{
TBL *t;
- int cnt, i;
+ int cnt;
wchar_t *p, **lp;
ssize_t *lens;
ssize_t maxcols = DEFCOLS, coloff;
@@ -347,8 +347,7 @@ static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy,
for (t = tbl, cnt = 0; cnt < entries; ++cnt, ++t) {
for (coloff = 0; coloff < t->cols - 1; ++coloff) {
fputws(t->list[coloff], stdout);
- for (i = lens[coloff] - t->len[coloff]; i > 0; i--)
- putwchar(' ');
+ wprintf(L"%*s", lens[coloff] - t->len[coloff], "");
fputws(colsep, stdout);
}
if (coloff < t->cols) {
--
1.8.3.4
next reply other threads:[~2013-08-03 23:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-03 23:15 Sami Kerola [this message]
2013-08-03 23:15 ` [PATCH 2/3] more: make output redirection more efficient Sami Kerola
2013-08-05 8:48 ` Karel Zak
2013-08-03 23:15 ` [PATCH 3/3] cal: set statically defined data read-only Sami Kerola
2013-08-05 8:49 ` Karel Zak
2013-08-05 8:48 ` [PATCH 1/3] column: use variable lenght printf field width to wprint blanks Karel Zak
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=1375571721-30008-1-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/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