From 8605284e0d1b70d9845ca4c6362d7d451f503d32 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 3 Oct 2011 10:54:08 -0500 Subject: Use puts() instead of no-op printf() where applicable This replaces several printf calls of the following styles: printf("%s", ...); printf("some fixed string"); printf("x"); We can use either fputs() or putchar() here to do the same thing without incurring the overhead of the printf format parser. The biggest gain here comes when we are calling the print function in a loop repeatedly; notably when printing local package files. $ /usr/bin/time ./pacman-before -Ql | md5sum 0.25user 0.04system 0:00.30elapsed 98%CPU $ /usr/bin/time ./pacman-after -Ql | md5sum 0.17user 0.06system 0:00.25elapsed 94%CPU $ /usr/bin/time ./pacman-before -Qlq | md5sum 0.20user 0.05system 0:00.26elapsed 98%CPU $ /usr/bin/time ./pacman-after -Qlq | md5sum 0.15user 0.05system 0:00.23elapsed 93%CPU So '-Ql' shows a 17% improvement while '-Qlq' shows a 13% improvement on 382456 total files. Signed-off-by: Dan McGee --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pacman/pacman.c') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 5ebced25..ac793dfc 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -208,7 +208,7 @@ static void usage(int op, const char * const myname) } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for (i = list; i; i = alpm_list_next(i)) { - printf("%s", (const char *)i->data); + fputs((const char *)i->data, stdout); } alpm_list_free(list); #undef addlist -- cgit v1.2.3-70-g09d2