[PATCH 2/2] ui-stats: do not duplicate string

Christian Hesse list at eworm.de
Mon Oct 12 10:59:35 CEST 2015


From: Christian Hesse <mail at eworm.de>

string_list_insert() expects (const char*), so no need to duplicate and
free the string.

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 ui-stats.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/ui-stats.c b/ui-stats.c
index 02335e7..26473de 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -171,24 +171,19 @@ static void add_commit(struct string_list *authors, struct commit *commit,
 	struct string_list_item *author, *item;
 	struct authorstat *authorstat;
 	struct string_list *items;
-	char *tmp;
 	struct tm *date;
 	time_t t;
 
 	info = cgit_parse_commit(commit);
-	tmp = xstrdup(info->author);
-	author = string_list_insert(authors, tmp);
+	author = string_list_insert(authors, info->author);
 	if (!author->util)
 		author->util = xcalloc(1, sizeof(struct authorstat));
-	free(tmp);
 	authorstat = author->util;
 	items = &authorstat->list;
 	t = info->committer_date;
 	date = gmtime(&t);
 	period->trunc(date);
-	tmp = xstrdup(period->pretty(date));
-	item = string_list_insert(items, tmp);
-	free(tmp);
+	item = string_list_insert(items, period->pretty(date));
 	item->util++;
 	authorstat->total++;
 	cgit_free_commitinfo(info);
-- 
2.6.1



More information about the CGit mailing list