[PATCH 1/3] column: use variable lenght printf field width to wprint blanks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes program to run a little faster.  My test input show about 20%
speed improvement.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 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

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




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux