[PATCH 2/4] column: Call mbs_to_wcs("") only once

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

 



Signed-off-by: Lennard Hofmann <lennard.hofmann@xxxxxx>
---
This is an optional patch to improve performance slightly while only
adding three lines of code.
 text-utils/column.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/text-utils/column.c b/text-utils/column.c
index bc7851472..d83d8d6d7 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -496,14 +496,18 @@ static void add_entry(struct column_control *ctl, size_t *maxents, wchar_t *wcs)
 	ctl->ents[ctl->nents] = wcs;
 }

-static void add_empty_entry(struct column_control *ctl, size_t *maxents)
+static void add_empty_entry(struct column_control *ctl, size_t *maxents,
+                            wchar_t *empty)
 {
-	add_entry(ctl, maxents, mbs_to_wcs(""));
+	if (empty == NULL)
+		empty = mbs_to_wcs("");
+	add_entry(ctl, maxents, empty);
 	ctl->nents++;
 }

 static int read_input(struct column_control *ctl, FILE *fp)
 {
+	wchar_t *empty = NULL;
 	char *buf = NULL;
 	size_t bufsz = 0;
 	size_t maxents = 0;
@@ -531,7 +535,7 @@ static int read_input(struct column_control *ctl, FILE *fp)
 				if (ctl->mode == COLUMN_MODE_TABLE)
 					add_emptyline_to_table(ctl);
 				else
-					add_empty_entry(ctl, &maxents);
+					add_empty_entry(ctl, &maxents, empty);
 			}
 			continue;
 		}
--
2.28.0




[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